import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.TreeSet; public class No43 { public static void main(String[] args) throws IOException{ //野球の試合 String[] str = readStr(); int N = Integer.parseInt(str[0]); char[][] s = new char[N][N]; for(int i = 0;i < N;i++) { s[i] = str[i+1].toCharArray(); } int ans = Math.min(judge(s , N) , N); System.out.println(ans); } public static int judge(char[][] s , int N) { int ans = N; for(int i = 0;i < N;i++) { for(int j = i+1;j < N;j++) { if(s[i][j] == '-') { s[i][j] = 'o'; s[j][i] = 'x'; ans = Math.min(judge(s , N) , ans); s[i][j] = 'x'; s[j][i] = 'o'; ans = Math.min(judge(s , N) , ans); return ans; } } } TreeSet ts = new TreeSet<>(); int my = 0; for(int i = 0;i < N;i++) { int count = 0; for(int j = 0;j < N;j++) { count += (s[i][j] == 'o' ? 1 : 0); } my += (i == 0 ? count : 0); ts.add(count); } Integer[] result = new Integer[ts.size()]; ts.toArray(result); for(int i = 0;i < result.length;i++) { if(result[i] == my) { ans = result.length - i; } } return ans; } public static String[] readStr() throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ArrayList list = new ArrayList<>(); do { list.add(br.readLine()); }while(br.ready()); br.close(); String[] text = new String[list.size()]; list.toArray(text); return text; } }