class Problem
  attr_accessor :a, :b, :c, :k, :n, :m, :h, :w
  def initialize
    @n,@k = gets.to_s.split.map{ |v| v.to_i }
  end

  def solve
    k == 1 ? 0 : n - k
  end

  def show(ans)
    puts ans
  end
end

Problem.new.instance_eval do
  show(solve)
end