(defn otoshidama [[N,Y]] (first (for [A (range (inc N)) B (range (inc N)) C (range (inc N)) :when (and (= N (+ A B C)) (= Y (+ (* 10000 A) (* 5000 B) (* 1000 C))))] [A B C])))
(println (otoshidama (map bigint (.split (read-line) " "))))