f=->{gets.split.map &:to_i};h=Hash.new 0;n,k=f[];p *n.times.map{|i|s,t,u=f[];[-s,u,t,i]}.sort.map{|e|e[1]=h[e[1]]+=1;e}.sort.map(&:last)[0,k]