def getMax(S,c): ret = 0 if c <= 0: rank = [0 for i in range(len(S))] v = S[0].count('o') for i in range(len(S)): rank[S[i].count('o')] += 1 r = 1 for i in range(len(S) - 1,-1,-1): if rank[i] == 0:continue if i == v: break r += 1 ret = r else: used = [[False for j in range(len(S))]for i in range(len(S))] for i in range(len(S)): for j in range(len(S)): if i == j:continue if used[i][j]:continue if S[i][j] == '-': S[i][j] = 'o' S[j][i] = 'x' ret = max(ret,getMax(S,c - 1)) S[i][j] = 'o' S[j][i] = 'x' ret = max(ret,getMax(S,c - 1)) S[i][j] = '-' S[j][j] = '-' used[i][j] = True used[j][j] = True return ret N = int(raw_input()) S = [list(raw_input()) for i in range(N)] for i in range(N): if S[0][i] == '-': S[0][i] = 'o' S[i][0] = 'x' c = sum([S[i].count('-') for i in range(N)]) / 2 print getMax(S,c)