x,n=map(int,input().split()) lst=sorted(int(input()) for _ in range(n-1))[::-1] for i,j in enumerate(lst): if x>=j and (i %10 <=3) :print(str(i+1)+["st","nd","rd"][i]);break else:print(str(i+2)+"th")