#include<stdio.h>#include<string.h>
int main()
{
int n,i,j,min,sum;
int count[20];
while(scanf("%d",&n),n)
{
char ch;
sum = 0;
memset(count,0,sizeof(count));
for(i=0; i<n; i++)
{
for(j=0; j<26; j++)
if((ch=getchar())==' ')
count[i]++;
sum += count[i];
if(i==0) min = count[i];
else if(count[i]<min) min = count[i];
}
printf("%d\n",sum-min*n);
}
return 0;
}
/*
4
XXXX XXXXX
XXX XXXXXXX
XXXXX XXXX
XX XXXXXX
2
XXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXX
1
XXXXXXXXX XX
0
*/