l, p = gets.chomp.split(" ").map &:to_i count = l/(p*2) puts "#{l - p*count}"