import java.util.Arrays; import java.util.LinkedList; import java.util.Scanner; public class Main { public static class Team implements Comparable { int degs, id; public Team(int degs, int id) { super(); this.degs = degs; this.id = id; } @Override public int compareTo(Team o) { if(Integer.compare(o.degs, this.degs) != 0){ return Integer.compare(o.degs, this.degs); }else{ return Integer.compare(this.id, o.id); } } @Override public String toString(){ return this.id + " : " + this.degs; } } public static int dfs(final int N, int x, int y, Team[] teams, boolean[][] undecided){ if(y == N){ Team[] sorted = new Team[N]; System.arraycopy(teams, 0, sorted, 0, N); Arrays.sort(sorted); for(int i = 0; i < N; i++){ if(sorted[i].id == 0){ return i + 1; } } return N; }else if(!undecided[y][x]){ return dfs(N, x == N - 1 ? y + 1 : x + 1, x == N - 1 ? y + 1 : y, teams, undecided); }else{ int ret = Integer.MAX_VALUE; { teams[y].degs++; teams[x].degs--; ret = Math.min(ret, dfs(N, x == N - 1 ? y + 1 : x + 1, (x == N - 1) ? y + 1 : y, teams, undecided)); teams[y].degs--; teams[x].degs++; } { teams[y].degs--; teams[x].degs++; ret = Math.min(ret, dfs(N, x == N - 1 ? y + 1 : x + 1, (x == N - 1) ? y + 1 : y, teams, undecided)); teams[y].degs++; teams[x].degs--; } return ret; } } public static void main(String[] args){ Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); Team[] teams = new Team[N]; for(int i = 0; i < N; i++){ teams[i] = new Team(0, i); } boolean[][] undecided = new boolean[N][N]; for(int i = 0; i < N; i++){ char[] inputs = sc.next().toCharArray(); for(int j = 0; j < N; j++){ if(inputs[j] == 'o'){ teams[i].degs++; teams[j].degs--; }else if(inputs[j] == '-'){ undecided[i][j] = true; } } } System.out.println(dfs(N, 0, 0, teams, undecided)); } }