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