m = {1:"st", 2:"nd", 3:"rd"} h, n = map(int, input().split()) H = [h] for _ in range(n - 1): H.append(int(input())) ans = sorted(H)[::-1].index(h) + 1 print(f"{ans}{m[ans] if ans % 10 in m else 'th'}")