import java.util.Arrays; import java.util.Scanner; public class Main_yukicoder43 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); char[][] s = new char[n][]; for (int i = 0; i < n; i++) { s[i] = sc.next().toCharArray(); } for (int i = 0; i < n; i++) { if (s[0][i] == '-') { s[0][i] = 'o'; s[i][0] = 'x'; } } int m = n * (n - 1) / 2; int min = Integer.MAX_VALUE; for (int i = 0; i < 0x1 << m; i++) { min = Math.min(min, getMin(s, i)); } System.out.println(min); sc.close(); } private static int getMin(char[][] s, int i) { int n = s[0].length; int[] cnt = new int[n]; for (int j = 0; j < n; j++) { for (int k = 0; k < n; k++) { if (j == k) { continue; } if (s[j][k] == 'o') { cnt[j]++; } } } out: for (int j = 1; j < n; j++) { int cnttmp = cnt[j]; for (int k = j + 1; k < n; k++) { int tmp = (n - 1 - j) * (n - 1 - j - 1) / 2 + n - 1 - k; boolean win = (i & 0x1 << tmp) != 0; if (s[j][k] == 'x' && win) { continue out; } else if (s[j][k] == '-' && win) { cnttmp++; } } cnt[j] = cnttmp; } int cnt0 = cnt[0]; Arrays.sort(cnt); int j; for (j = n - 1; j >= 0; j--) { if (cnt[j] <= cnt0) { break; } } return n - j; } }