h, n = input().split() lis = sorted([input() for _ in range(int(n)-1)] + [h], reverse=True) for i in range(int(n)): if lis[i] == h: v = str(i+1)[-1] a = "st" if v == "1" else ("nd" if v == "2" else ("rd" if v == "3" else "th")) print(f"{i+1}{a}") break