with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Solve is
   N : Integer;
   Ans : Integer;
begin
   Get (N);
   Ans := (N+1000-1)/1000*1000-N;
   Put_Line (Integer'Image (Ans));
end Solve;