H, N = map(int, input().split()) T = [input().rstrip() for i in range(N-1)] T = [int(i) for i in T] T.append(H) T.sort(reverse=True) c = (T.index(H) + 1) % 10 if c == 1: print(str(c) + "st") elif c == 2: print(str(c) + "nd") elif c == 3: print(str(c) + "rd") else: print(str(c) + "th")