A,B = gets.split.map(&:to_i) L = ((0...B).map {|x| gets.to_i} + [A]).sort puts %w(th st nd rd th th th th th th)[L.index(A) % 10]