defmodule Main do
  def main do
    IO.gets("")
    |> String.trim()
    |> String.to_integer()
    |> get_change()
    |> IO.puts()
  end
 
  def get_change(m) do
    u=1000
    rem(rem(-m, u)+u,u)
  end
end
