from itertools import product N = input() league = [list(raw_input()) for _ in xrange(N)] for i in xrange(N): if league[0][i] == '-': league[0][i] = 'o' league[i][0] = 'x' unfixed = [] for i in xrange(N): for j in xrange(i+1, N): if league[i][j] == '-': unfixed.append((i, j)) rank = map(lambda x:x.count('o'), league) ans = sum([r > rank[0] for r in rank])+1 for ox in product('ox', repeat=len(unfixed)): for k in xrange(len(unfixed)): i, j = unfixed[k] league[i][j] = ox[k] league[j][i] = 'o' if ox[k] == 'x' else 'x' rank = map(lambda x:x.count('o'), league) ans = min(ans, sum([r > rank[0] for r in rank])+1) print ans