import sys import math import functools import itertools import copy def solve(): N = int(input()) S = [ input() for _ in range(N) ] tmp = copy.deepcopy(S) ans_c1 = 0 for i, s in enumerate(S): if '#' not in s[:N-1]: ans_c1 += 1 tmp[i] = (N-1)*'#'+ tmp[i][N-1] else: st = list(zip(*tmp)) if '#' not in st[0] or '#' not in st[N-1]: ans_c1 += 1 tmp = copy.deepcopy(S) ans_c2 = 0 for i, s in enumerate(S): if '#' not in s[1:N]: ans_c2 += 1 tmp[i] = tmp[i][0] + (N-1)*'#' else: st = list(zip(*tmp)) if '#' not in st[0] or '#' not in st[N-1]: ans_c2 += 1 tmp = list(map(list, zip(*S))) ans_r1 = 0 for i, s in enumerate(list(map(list, zip(*S)))): if '#' not in s[:N-1]: ans_r1 += 1 tmp[i] = (N-1)*'#' + tmp[i][N-1] else: st = list(zip(*tmp)) if '#' not in st[0] or '#' not in st[N-1]: ans_r1 += 1 tmp = list(zip(*S)) ans_r2 = 0 for i, s in enumerate(list(zip(*S))): if '#' not in s[1:N]: ans_r2 += 1 tmp[i] = tmp[i][0] + (N-1)*'#' else: st = list(zip(*tmp)) if '#' not in st[0] or '#' not in st[N-1]: ans_r2 += 1 at = sorted([ans_r1, ans_r2, ans_c1, ans_c2]) if at[-1] >= 4: print(at[-1]) else: if '#' not in S[0] and '#' not in S[N-1] and '#' not in list(zip(*S))[0] and '#' not in list(zip(*S))[N-1]: print(4) else: print(at[-1]) if __name__ == "__main__": solve()