#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { int n; cin >> n; vector Grid(n, vector(n)); rep(i, n) rep(j, n) cin >> Grid[i][j]; vector> id(0); for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { id.push_back({ i, j }); } } assert(id.size() <= 15); int ans = 1e9; rep(bit, 1 << id.size()) { bool ok = true; vector cnt(n, 0); rep(i, id.size()) { auto [x, y] = id[i]; if (bit & (1 << i)) { if (Grid[x][y] == 'o' || Grid[x][y] == '-') ++cnt[x]; else ok = false; } else { if (Grid[x][y] == 'x' || Grid[x][y] == '-') ++cnt[y]; else ok = false; } } if (ok) { set st(cnt.begin(), cnt.end()); map mp; int cur = 0; for (auto x : st) mp[x] = cur++; ans = min(ans, cur - mp[cnt[0]]); } } cout << ans << endl; return 0; }