defmodule Main do
  def main do
    n = IO.gets("") |> String.trim() |> String.to_integer()
    1..10
    |> Enum.reduce_while(0, fn _, payment ->
      if payment < n, do: {:cont, payment + 1000}, else: {:halt, payment}
    end)
    |> Kernel.-(n)
    |> IO.puts()
  end
end