h, n = map(int, input().split()) data = [h] for i in range(n-1): data.append(int(input())) data.sort(reverse=True) m = data.index(h) + 1 print(data) i = m%10 if i == 1: print("%dst" % m) elif i == 2: print("%dnd" % m) elif i == 3: print("%drd" % m) else: print("%dth" % m)