N = int(input()) g = [list(input()) for _ in range(N)] def dfs(g, yx): if yx == N * N: win = [g[i].count('o') for i in range(N)] return list(set(win))[::-1].index(win[0]) + 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)) g[y][x], g[x][y] = '-', '-' return res print(dfs(g, 0))