l, k = gets.chomp!.split(' ').map(&:to_i) def yuukun(l, k) if l - 2 * k <= 0 0 else k + yuukun(l - 2 * k, k) end end puts yuukun(l, k)