import itertools N = int(input()) S = [list(input()) for _ in range(N)] for i in range(N): if S[0][i] == '-': S[0][i] = 'o' S[i][0] = 'x' count = 0 for s in S: for m in s: if m == '-': count += 1 rg = count//2 WL = ('o','x') pat = [] for p in itertools.product(WL, repeat=rg): pat.append(list(p)) CS = [x[:] for x in S] rup = [] for g in pat: wn = [] for idx, ss in enumerate(S): for idxx, sss in enumerate(ss): if CS[idx][idxx] == '-': wl = g.pop() if wl == 'o': CS[idx][idxx] = 'o' CS[idxx][idx] = 'x' else: CS[idx][idxx] = 'x' CS[idxx][idx] = 'o' for cs in CS: w = cs.count('o') wn.append(w) tw = wn[0] wn = sorted(wn, reverse=True) rank = wn.index(tw) + 1 rup.append(rank) CS = [x[:] for x in S] print(min(rup))