#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,l;
int ii,jj;
int qx[4]={0,1,0,-1};
int qy[4]={1,0,-1,0};
void ff(int x,int y)
{
int i,j;
g[x][y]=false;
for (i=0;i<=3;i++)
{
if (g[x+qx[i]][y+qy[i]])
{
ff(x+qx[i],y+qy[i]);
g[x+qx[i]][y+qy[i]]=false;
}
}
}
int main()
{
int i,j,k;
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]<'a')||(s[j]>'z'))
f[i][j+1]=9;
else
{
f[i][j+1]=1;
g[i][j+1]=true;
}
}
}
l=0;
for (i=1;i<=n;i++)
if (l<=a[i]) l=a[i];
/* for (i=1;i<=n;i++)
{
for (j=1;j<=l;j++)
fout<<f[i][j]<<' ';
fout<<endl;
}*/
for (i=1;i<=n;i++)
for (j=1;j<=l;j++)
if ((f[i][j]==1)&&(g[i][j]))
{
ans++;
ff(i,j);
}
fout<<ans<<endl;
return 0;
}