wai,nin=input().split() ls=[] for i in range(int(nin)-1): ls.append(input()) ls.append(wai) ls=list(map(int,ls)) ls.sort() ls.reverse() ans=ls.index(int(wai))+1 if ans==1: print("1st") elif ans==2: print("2nd") elif ans==3: print("3nd") else: print(str(ans)+"th")