#! ruby # yukicoder My Practice # author: Leonardone @ NEETSDKASU (N, M), c = $<.map{|x| x.split.map(&:to_i)} M.times do c.sort_by!{|x| x == 0 ? 10**5 : x} c[0] -= 1 end puts c.count(0)