#include<fstream>
#include<string>
using namespace std;
ifstream fin("family.in");
ofstream fout("family.out");
int a[102]={0};
int f[202][202]={0};
bool g[202][202]={false};
int n,ans=0;
int qx[4]={0,1,0,-1};
int qy[4]={-1,0,1,0};
void ff(int x,int y)
{
int i,j;
for (i=1;i<=4;i++)
if (g[x+qx[i]][y+qy[i]])
{
g[x+qx[i]][y+qy[i]]=false;
ff(x+qx[i],y+qy[i]);
}
}
int main()
{
int i,j,k,l;
fin>>n;
string s;
for (i=0;i<=101;i++)
for (j=0;j<=201;j++)
f[i][j]=9;
getline(fin,s,'\n');
for (i=1;i<=n;i++)
{
getline(fin,s,'\n');
l=s.length();
a[i]=l;
for (j=0;j<l;j++)
{
if ((s[j]=='*')||(s[j]==' '))
f[i][j+1]=9;
else
{
f[i][j+1]=1;
g[i][j+1]=true;
}
}
}
for (i=1;i<=n;i++)
{
for (j=1;j<=a[i];j++)
fout<<f[i][j]<<' ';
fout<<endl;
}
for (i=1;i<=n;i++)
for (j=1;j<=a[i];j++)
if ((f[i][j]==1)&&(g[i][j]))
{
ans++;
ff(i,j);
}
fout<<ans<<endl;
return 0;
}