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