defmodule Main do       
def main do             
IO.gets("") |> String.trim() |> String.to_integer() |> solve()
end
 
def solve(maney) when maney > 1000, do: solve(maney-1000)
def solve(0, _), do: IO.puts(0)
def solve(maney) when maney <= 1000, do: IO.puts(1000 - maney)
end