defmodule Main do
  def main do
    IO.gets("")
    |> String.trim()
    |> String.to_integer()
    |> solve()
    |> IO.puts()
  end

  @doc ~S"""
  Sove

  ## Examples

      iex> Main.solve(1900)
      100
      iex> Main.solve(3000)
      0

  """
  def solve(n) do
    1..10
    |> Enum.reduce_while(0, fn _, payment ->
      if payment < n, do: {:cont, payment + 1000}, else: {:halt, payment}
    end)
    |> Kernel.-(n)
  end
end