N = int(input()) S = [input() for _ in range(N)] W0 = [0] * N G = [] for i in range(N - 1): for j in range(i + 1, N): if S[i][j] == "o": W0[i] += 1 elif S[i][j] == "x": W0[j] += 1 else: G.append((i, j)) NG = len(G) ans = 6 for i in range(1 << NG): W = W0[:] for j in range(NG): if i & (1 << j): W[G[j][0]] += 1 else: W[G[j][1]] += 1 w0 = W[0] cnt = 1 for k in range(6, w0, -1): if k in W: cnt += 1 ans = min(ans, cnt) print(ans)