#include using namespace std; #define rep(i,n) for(int (i) = 0 ; (i) < (int)(n) ; (i)++) #define REP(i,a,b) for(int (i) = a ; (int)(i) <= (int)(b) ; (i)++) #define all(n) (n).begin(),(n).end() typedef long long ll; typedef vector Vi; typedef vector VVi; typedef pair Pii; typedef vector VPii; char s[6][6]; int res = 1e9; int N; int f(int x,int y){ if( x >= N ) x = 0 , y++; if( y >= N ){ int r[6] = {}; for(int i = 0 ; i < N ; i++){ for(int j = 0 ; j < N ; j++){ if( s[i][j] == 'o' ) r[i]++; } } int rr = 0; vector u; for(int i = 0 ; i < N ; i++) u.push_back(r[i]); sort(u.rbegin(),u.rend()); u.erase(unique(u.begin(),u.end()),u.end()); res = min(res,find(u.begin(),u.end(),r[0]) - u.begin() + 1); return 0; } if( s[y][x] == '-' ){ s[y][x] = 'o'; s[x][y] = 'x'; f(x+1,y); s[y][x] = s[x][y] = '-'; s[y][x] = 'x'; s[x][y] = 'o'; f(x+1,y); s[y][x] = s[x][y] = '-'; }else{ f(x+1,y); } } int main(){ cin >> N; rep(i,N)rep(j,N) cin >> s[i][j]; f(0,0); cout << res << endl; }