import copy N = int(input()) lsS = [list(input()) for i in range(N)] for i in range(1,N): if lsS[0][i] == '-': lsS[0][i] = 'o' lsS[i][0] = 'x' lsmi = [] for i in range(N-1): for j in range(i+1,N): if lsS[i][j] == '-': lsmi.append((i,j)) M = len(lsmi) ans = 10 for i in range(2**M): lsS1 = copy.deepcopy(lsS) for j in range(M): if (i >> j)&1: a,b = lsmi[j] lsS1[a][b] = 'o' lsS1[b][a] = 'x' else: a,b = lsmi[j] lsS1[b][a] = 'o' lsS1[a][b] = 'x' ls = [] for i in range(N): ls.append((lsS1[i].count('o'),i)) ls.sort(reverse=True) cnt = 0 win = 100 lsrank = [0]*(N) for i in range(N): if win != ls[i][0]: cnt += 1 lsrank[ls[i][1]] = cnt win = ls[i][0] else: lsrank[ls[i][1]] = cnt ans = min(lsrank[0],ans) print(ans)