n = int(input()) renchon = "nyanpass" tab = [0 for _ in range(n)] for _ in range(n): sli = input().split() for i in range(n): if sli == renchon: tab[i] += 1 res = max(tab) if res == 0: print(-1) else: print(res if tab.count(res) == 1 else -1)