defmodule Main do
  def main do
      x =
      IO.read(:line)
      |> String.trim
      |> String.to_integer
	  a =
      IO.read(:line)
      |> String.trim
      |> String.to_integer
      b =
      IO.read(:line)
      |> String.trim
      |> String.to_integer
      IO.puts(rem((x - a), b))
  end
end
