defmodule Main do
  def main do
	[n, k] = IO.read(:line)
      |> String.trim()
      |> String.split()
      |> Enum.map(&String.to_integer/1)
      if n
	if n >= k do
    	ans = rem(n, k)
    
	IO.puts ans
  end
end
