import java.io.*; import java.util.ArrayList; import java.util.Arrays; class Main{ static final PrintWriter out=new PrintWriter(System.out); static final int INF=Integer.MAX_VALUE/2; static class Pair{ int x; int y; Pair(int x,int y){ this.x=x; this.y=y; } } public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String line=""; while((line=br.readLine())!=null&&!line.isEmpty()){ int n=Integer.parseInt(line); int[][] res=new int[n][n]; int[] win=new int[n]; ArrayList<Pair> array=new ArrayList<Pair>(); for(int i=0;i<n;i++){ line=br.readLine(); for(int j=0;j<n;j++){ char c=line.charAt(j); if(c=='#'||c=='x') res[i][j]=0; if(c=='o'){ res[i][j]=1; win[i]++; } if(c=='-'){ res[i][j]=INF; if(i<j&&i!=0){ array.add(new Pair(i,j)); } } } } for(int i=0;i<n;i++){ if(res[0][i]==INF){ res[0][i]=1; res[i][0]=0; win[0]++; } } int ans=INF; dfs(0,ans,res,win,array); out.println(ans); out.flush(); } } private static void dfs(int depth,int ans,int[][] res,int[] win,ArrayList<Pair> array){ if(depth==array.size()){ int r=checkRank(win); ans=Math.min(ans,r); return; } Pair p=array.get(depth); int x=p.x; int y=p.y; res[x][y]=1; res[y][x]=0; win[x]++; dfs(depth+1,ans,res,win,array); win[x]--; res[x][y]=0; res[y][x]=1; win[y]++; dfs(depth+1,ans,res,win,array); } private static int checkRank(int[] win){ int[] winc=win.clone(); int cnt=1; int prev=INF; Arrays.sort(winc); for(int i=winc.length-1;i>=0;i--){ if(win[0]<winc[i]){ if(prev!=winc[i]) cnt++; prev=winc[i]; } if(win[0]==winc[i]) return cnt; } return -1; } }