N = int(input()) X = [i for i in range(1000)] for i in range(N): X[len(input()) - 2] += 10000 print(max(X) % 10000)