def ri() gets.split.map &:to_i end N, k=ri D = {} for v in ri do if not D[v]; D[v]=0 end D[v] += 1 end c = 0 for v in D.each_value.sort.reverse do c += 1 k -= v break if k <=0 end p c