have_num, take_num = gets.split.map(&:to_i)
 
if take_num == 1
  return 0
elsif have_num == take_num || have_num - take_num == 1
  return 1
else
  continuing_num = have_num - (take_num - 1)
  return continuing_num
end