(defn input []
  (->> (repeatedly 2 read-line)
    (into []
      (comp (mapcat #(clojure.string/split % #"\s"))
        (map #(Integer/parseInt %))))))

(defn CandyDistributionAgain [[N x & As]]
  (let [[C S](->> (sort As)
               (reductions +)
               (take-while (partial >= x))
               ((juxt count last)))]
    (cond
      (= x S) C
      (= C 0) 0
      (< C N)  C
      (= C N) (dec C))))

(->> (input)
  CandyDistributionAgain
  println)