(defmacro inner-input []
  '(Integer/parseInt (read-line)))

(defn input []
  (list (inner-input) (inner-input)))

(defn AdditionAndMultiplication [[N K]]
  (let [As (->> 1 (iterate (partial * 2)) (take-while (partial >= K)))]
    (if (<= N (count As))
      (* 2 (last As))
      (+ (* 2(last As))
        (* K (- N (count As)))))))


(-> (input)
  AdditionAndMultiplication
  println)