#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using ll = long long; using namespace std; const ll MOD = 1e9 + 7; #define REP(i, n) for (int(i) = 0; (i) < (n); ++(i)) #define repi(i, a, b) for (int i = int(a); i < int(b); ++i) // bool operator<(const pair &a, const pair &b) // { // if (a.first == b.first) // return a.second < b.second; // return a.first < b.first; // }; /*unsigned int xor128(void) { static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123; unsigned int t = (x ^ (x << 11)); x = y; y = z; z = w; return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))); } unsigned int xor128rnd(unsigned int m) { return xor128() % m; }*/ /*bool operator<(const pair &a, const pair &b) { if (a.first == b.first) { return a.second < b.second; } return a.first < b.first; }*/ int ans = 1000000; int N; void dfs(vector &v) { bool check = true; for (int i = 0; i < N; ++i) { for (int j = i + 1; j < N; ++j) { if (v[i][j] == '-') { check = false; v[i][j] = 'o'; v[j][i] = 'x'; dfs(v); v[i][j] = 'x'; v[j][i] = 'o'; dfs(v); } } } if (check) { int arr[N] = {0}; for (int i = 0; i < N; ++i) { for (int j = 0; j < N; ++j) { if (v[i][j] == 'o') arr[i]++; } //cout << arr[i] << endl; } int t = arr[0]; sort(arr, arr + N); for (int i = N - 1; i >= 0; --i) { if (arr[i] == t) { ans = min(ans, N - i); break; } } return; } } int main(void) { cin.tie(0); ios::sync_with_stdio(false); cin >> N; vector v; for (int i = 0; i < N; ++i) { string s; cin >> s; v.push_back(s); } dfs(v); cout << ans << endl; return 0; }