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