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