1. 
/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 414 Machined Surfaces
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=6&page=show_problem&problem=355
*
* @author Felix Dietrich
* @version 1.0, 06/01/2010
*
* Method : Minimale Space-breite
* Status : Accepted
* Runtime: 0.120
*/


import java.util.*;
import java.lang.*;

class Main
{
interface Func<T,U>
{
U execute(T arguments);
}

public static <T,U> List<U> map(List<T> source, Func<T,U> f)
{
List<U> result = new ArrayList<U>();
for(T s: source)
result.add(f.execute(s));
return result;
}

public static int sum(List<Integer> source)
{
int result=0;
for(int s: source)
result += s;
return result;
}

public static int min(List<Integer> source)
{
int min = 999;
for(int i: source)
if(i < min)
min = i;
return min;
}

public static int countChar(String s, char c)
{
int result = 0;
for(char k: s.toCharArray())
{
if(c == k)
result++;
}
return result;
}

public static void main(String... args)
{
Scanner sc = new Scanner(System.in);
List<Integer> whitespaces = new ArrayList<Integer>();
String input;
int min = 0;
int result;
int len;

while(sc.hasNext())
{
whitespaces.clear();
len = Integer.parseInt(sc.nextLine());
if(len == 0)
return;
for(int i=0; i<len;i++)
{
input = sc.nextLine();
whitespaces.add(countChar(input,' '));
}

min = min(whitespaces);
result = 0;
for(int i: whitespaces)
{
result+=i-min;
}

System.out.println(result);
}
}
}