def main(): H, N = map(int, input().split()) hs = [H] + [int(input()) for _ in range(N - 1)] rank = sorted(hs, reverse=True).index(H) + 1 if rank % 10 == 1: print("1st") elif rank % 10 == 2: print("2nd") elif rank % 10 == 3: print("3rd") else: print(str(rank) + "th") if __name__ == '__main__': main()