def cul(r): res = 0 for i in r: if i == "o": res += 1 return res def main(): n = int(input()) s = [list(input()) for i in range(n)] score = [0] * n for i in range(n): if s[0][i] == "-": s[0][i], s[i][0] = "o", "x" score[0] = cul(s[0]) uncertain = [] for i in range(n): for j in range(i+1, n): if s[i][j] == "-": uncertain.append((i, j)) ans = n for i in range(2**len(uncertain)): for j in range(len(uncertain)): k, l = uncertain[j] if (i >> j) & 1: s[k][l], s[l][k] = "o", "x" else: s[k][l], s[l][k] = "x", "o" cnt = 1 for j in range(n): score[j] = cul(s[j]) if score[0] < score[j]: cnt += 1 ans = min(ans, cnt) for j in range(len(uncertain)): k, l = uncertain[j] s[k][l] = s[l][k] = "-" print(ans) if __name__ == '__main__': main()