h,n=map(int,input().split()) l=[int(input()) for i in[0]*~-n]+[h] p=sorted(l,reverse=1).index(h)+1 a="st"+"nd"+"rd"+"th"*9 c=p%10 print(p,a[~-c*2:c*2],sep="")