import java.util.*;
import java.io.*;
import java.math.*;
 
 
public class Main
{
    public static void main(String[] args) 
    { 
          Scanner input=new Scanner(System.in);
          int n = input.nextInt();
        //   String s = input.next();
        int count =0;
        int i=1000;
          while(i<n){
              i=i+1000;
            //   count=i;
          }
          
          
          System.out.println(i-n);
          
          
      
            
          input.close(); 
     } 
     
} import java.util.*; util.* java import java.io.*; io.* java import java.math.*; math.* java public class Main
{
    public static void main(String[] args) 
    { 
          Scanner input=new Scanner(System.in);
          int n = input.nextInt();
        //   String s = input.next();
        int count =0;
        int i=1000;
          while(i<n){
              i=i+1000;
            //   count=i;
          }
          
          
          System.out.println(i-n);
          
          
      
            
          input.close(); 
     } 
     
} Main public static void main(String[] args) 
    { 
          Scanner input=new Scanner(System.in);
          int n = input.nextInt();
        //   String s = input.next();
        int count =0;
        int i=1000;
          while(i<n){
              i=i+1000;
            //   count=i;
          }
          
          
          System.out.println(i-n);
          
          
      
            
          input.close(); 
     } main { 
          Scanner input=new Scanner(System.in);
          int n = input.nextInt();
        //   String s = input.next();
        int count =0;
        int i=1000;
          while(i<n){
              i=i+1000;
            //   count=i;
          }
          
          
          System.out.println(i-n);
          
          
      
            
          input.close(); 
     } Scanner input=new Scanner(System.in); input new Scanner(System.in) int n = input.nextInt(); n input.nextInt() input.nextInt input int count =0; count 0 int i=1000; i 1000 while(i<n){
              i=i+1000;
            //   count=i;
          } i<n i n {
              i=i+1000;
            //   count=i;
          } i=i+1000 i i+1000 i 1000 System.out.println(i-n) System.out.println System.out System System.out i-n i n input.close() input.close input String[] args args public class Main
{
    public static void main(String[] args) 
    { 
          Scanner input=new Scanner(System.in);
          int n = input.nextInt();
        //   String s = input.next();
        int count =0;
        int i=1000;
          while(i<n){
              i=i+1000;
            //   count=i;
          }
          
          
          System.out.println(i-n);
          
          
      
            
          input.close(); 
     } 
     
} public class Main
{
    public static void main(String[] args) 
    { 
          Scanner input=new Scanner(System.in);
          int n = input.nextInt();
        //   String s = input.next();
        int count =0;
        int i=1000;
          while(i<n){
              i=i+1000;
            //   count=i;
          }
          
          
          System.out.println(i-n);
          
          
      
            
          input.close(); 
     } 
     
} Main
import java.util.*;
import java.io.*;
import java.math.*;
 
 
public class Main
{
    public static void main(String[] args) 
    { 
          Scanner input=new Scanner(System.in);
          int n = input.nextInt();
        //   String s = input.next();
        int count =0;
        int i=1000;
          while(i<n){
              i=i+1000;
            //   count=i;
          }
          
          
          System.out.println(i-n);
          
          
      
            
          input.close(); 
     } 
     
}