l, k = gets.split.map(&:to_i) q, r = l.divmod(2 * k) q -= 1 if r == 0 #ぴったり食べきったら唇が触れる puts k * q