def getMin(S,c,used): 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 return ret else: for i in range(1,N): for j in range(1,N): if i == j:continue if used[i][j] or used[j][i]:continue if S[j][i] == 'u':continue if S[i][j] == '-': S[i][j] = 'o' S[j][i] = 'x' ret = min(ret,getMin(S,c - 1,used)) S[i][j] = 'x' S[j][i] = 'o' ret = min(ret,getMin(S,c - 1,used)) used[i][j] = True used[j][i] = 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 used = [[False for j in range(N)] for i in range(N)] print getMin(S,c,used)