s,n = gets.chomp.split(" ").map(&:to_i) a = [] a << s (n - 1).times { a << gets.chomp.to_i} a = a.sort.reverse z = a.index(s) + 1 case z when 1 suffix = "st" when 2 suffix = "nd" when 3 suffix = "rd" else suffix = "th" end puts "#{z}#{suffix}"