height, test_case = gets.chomp.split().map(&:to_i) height_list = Array.new for i in 0...(test_case - 1) do height_list << gets.chomp.to_i end height_list << height height_list.sort!{|a, b| b <=> a } res = 0 height_list.each_with_index{ |element, value| if height == element res = value + 1 break end } print res if res == 1 puts "st" elsif res == 2 puts "nd" elsif res == 3 puts "rd" else puts "th" end