N = int(input()) g = [list(input()) for _ in range(N)] def dfs(g, yx): if yx == N * N: win = [0] * N for i in range(N): for j in range(N): if g[i][j] == 'o': win[i] += 1 res = 0 for x in set(win): if win[0] == x: return len(set(win)) - res res += 1 y, x = yx // N, yx % N if g[y][x] != '-': return dfs(g, yx + 1) res = 100 g[y][x], g[x][y] = 'o', 'x' res = min(res, dfs(g, yx + 1)) g[y][x], g[x][y] = 'x', 'o' res = min(res, dfs(g, yx + 1)) return res print(dfs(g, 0))