#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
char str[120];
int main(){
#ifdef LOCAL
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif
int n, count[15], maxs, sum;
while(scanf("%d", &n),n){
memset(count, 0, sizeof(count));
sum = 0;
maxs = 0;
getchar();
for(int i = 0; i < n; i++){
gets(str);
//puts(str);
for(int j = 0; j < strlen(str); j++){
if(str[j] == 'X') count[i]+= 1;
}
if(count[i] > maxs) maxs = count[i];
}
for(int i = 0; i< n; i++){
sum+=maxs - count[i];
}
printf("%d\n", sum);
}
return 0;
}
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
char str[120];
int main(){
#ifdef LOCAL
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif
int n, count[15], maxs, sum;
while(scanf("%d", &n),n){
memset(count, 0, sizeof(count));
sum = 0;
maxs = 0;
getchar();
for(int i = 0; i < n; i++){
gets(str);
//puts(str);
for(int j = 0; j < strlen(str); j++){
if(str[j] == 'X') count[i]+= 1;
}
if(count[i] > maxs) maxs = count[i];
}
for(int i = 0; i< n; i++){
sum+=maxs - count[i];
}
printf("%d\n", sum);
}
return 0;
}