nama, n = input().split() n = int(n) a1 = [input() for i in range(n)] a1.append(nama) a1.remove("") a = sorted([int(i) for i in a1], reverse=True) rank = a.index(int(nama)) + 1 if rank == 1: print("1st") elif rank == 2: print("2nd") elif rank == 3: print("3rd") else: print(str(rank) + "th")