H, N = map(int, input().split()) s = [int(input()) for _ in range(N-1)] aft = ["st", "nd", "rd", "th"] l = s + [H] l.sort() idx = l.index(H) last = idx % 10 idx = str(idx) if last == 1: print(idx+aft[0]) elif last == 2: print(idx+aft[1]) elif last == 3: print(idx+aft[2]) else: print(idx+aft[3])