(defn AtCoderCrackers [N K]
  (let [r (rem N K)]
    (if (zero? r)
      0
      (let [d (quot N K)]
        (if (< K d)
          (- K r)
          r)))))
(println (AtCoderCrackers (int (read)) (int (read))))