#include #define rep(i, n) for(long long i = 0; i < n; i++) #define ALL(v) (v).begin(), (v).end() using namespace std; using lint = long long; int main() { int n; cin >> n; vector> s(n, vector(n)); rep(i, n) { rep(j, n) { cin >> s[i][j]; } } vector> v; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (s[i][j] == '-') { v.emplace_back(i, j); } } } int sz = v.size(); auto calc = [&](vector> s) -> int { vector cnt(n, 0); rep(i, n) rep(j, n) { if (s[i][j] == 'o') { cnt[i]++; } } vector> lst(100); rep(i, n) { lst[cnt[i]].emplace_back(i); } int res = 1; for (int i = 99; i >= 0; i--) { for (int x : lst[i]) { if (x == 0) { return res; } } if (lst[i].size() > 0) { res++; } } }; int ans = 100; rep(bit, (1 << sz)) { vector> t = s; rep(i, sz) { auto [x, y] = v[i]; if (bit & (1 << i)) { t[x][y] = 'o'; t[y][x] = 'x'; } else { t[x][y] = 'x'; t[y][x] = 'o'; } } ans = min(ans, calc(t)); } cout << ans << endl; }