#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; struct ST { int s; int i; }; bool operator<(const ST& a, const ST& b){ if(a.s == b.s) return a.i < b.i; return a.s > b.s; } int ret; void dfs(vector& v){ rep(i,v.size()){ rep(j,v.size()){ if(v[i][j] == '-'){ v[i][j] = 'o'; v[j][i] = 'x'; dfs(v); v[i][j] = 'x'; v[j][i] = 'o'; dfs(v); v[i][j] = '-'; v[j][i] = '-'; return; } } } vector w(v.size(), 0); rep(i,v.size()){ rep(j,v.size()){ if(v[i][j]=='o') w[i]++; } } vector ww; rep(i,v.size()) ww.push_back((ST){w[i],i}); sort(ALLOF(ww)); rep(i,v.size()){ if(ww[i].i == 0){ ret = min(ret, i+1); return; } } } int main(){ int N; vector v; cin >> N; rep(i,N){ string str; cin >> str; v.push_back(str); } ret = 10; dfs(v); cout << ret << endl; return 0; }