n = int(input()) ref = ["akai", "marui", "okii", "umai"] ref.sort() cnt = 0 for _ in range(n): s = list(input().split()) s.sort() print(ref, s) if "".join(ref) == "".join(s): cnt += 1 print(cnt)