H,N=map(int,input().split()) X=[0]*N X[0]=H for _ in range(1,N): X[_]=int(input()) X.sort(reverse=True) for i in range(N): if H==X[i]: if i==0 or i%10==0: print(str(i+1)+"st");exit() elif i==1 or i%10==1: print(str(i+1)+"nd");exit() elif i==2 or i%10==2: print(str(i+1)+"rd");exit() else: print(str(i+1)+"th");exit()