def getMin(S,c): ret = 99 N = len(S) if c <= 0: rank = [0 for i in range(N)] v = S[0].count('o') for i in range(N): rank[S[i].count('o')] += 1 r = 1 for i in range(N - 1,-1,-1): if rank[i] == 0:continue if i == v: break r += 1 ret = r else: used = [[False for j in range(N)]for i in range(N)] for i in range(N): for j in range(N): if i == j:continue if used[i][j]:continue if used[j][i]:continue if S[i][j] == '-': S[i][j] = 'o' S[j][i] = 'x' ret = min(ret,getMin(S,c - 1)) S[i][j] = 'x' S[j][i] = 'o' ret = min(ret,getMin(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(1,N): if S[0][i] == '-': S[0][i] = 'o' S[i][0] = 'x' c = sum([S[i].count('-') for i in range(1,N)]) / 2 print getMin(S,c)