import java.util.Scanner;

public class Main {

                 public static void main(String[] args) {
                                  Scanner ob = new Scanner(System.in);

                                  int n = ob.nextInt();
                                  for(int i=1;i<1000;i++)
                                  {
                                  if(i*1000==n){System.out.println(0);break;}
                                  if((i*1000)>n)
                                  {
                                                   System.out.println((int)Math.abs((i*1000)-n));
                                                   break;
                                  }
                                  }
                              //    System.out.println((int)Math.abs(n-1000));
                 }

} import java.util.Scanner; Scanner java.util public class Main {

                 public static void main(String[] args) {
                                  Scanner ob = new Scanner(System.in);

                                  int n = ob.nextInt();
                                  for(int i=1;i<1000;i++)
                                  {
                                  if(i*1000==n){System.out.println(0);break;}
                                  if((i*1000)>n)
                                  {
                                                   System.out.println((int)Math.abs((i*1000)-n));
                                                   break;
                                  }
                                  }
                              //    System.out.println((int)Math.abs(n-1000));
                 }

} Main public static void main(String[] args) {
                                  Scanner ob = new Scanner(System.in);

                                  int n = ob.nextInt();
                                  for(int i=1;i<1000;i++)
                                  {
                                  if(i*1000==n){System.out.println(0);break;}
                                  if((i*1000)>n)
                                  {
                                                   System.out.println((int)Math.abs((i*1000)-n));
                                                   break;
                                  }
                                  }
                              //    System.out.println((int)Math.abs(n-1000));
                 } main {
                                  Scanner ob = new Scanner(System.in);

                                  int n = ob.nextInt();
                                  for(int i=1;i<1000;i++)
                                  {
                                  if(i*1000==n){System.out.println(0);break;}
                                  if((i*1000)>n)
                                  {
                                                   System.out.println((int)Math.abs((i*1000)-n));
                                                   break;
                                  }
                                  }
                              //    System.out.println((int)Math.abs(n-1000));
                 } Scanner ob = new Scanner(System.in); ob new Scanner(System.in) int n = ob.nextInt(); n ob.nextInt() ob.nextInt ob for(int i=1;i<1000;i++)
                                  {
                                  if(i*1000==n){System.out.println(0);break;}
                                  if((i*1000)>n)
                                  {
                                                   System.out.println((int)Math.abs((i*1000)-n));
                                                   break;
                                  }
                                  } int i=1; int i=1; i 1 i<1000 i 1000 i++ i++ i {
                                  if(i*1000==n){System.out.println(0);break;}
                                  if((i*1000)>n)
                                  {
                                                   System.out.println((int)Math.abs((i*1000)-n));
                                                   break;
                                  }
                                  } {
                                  if(i*1000==n){System.out.println(0);break;}
                                  if((i*1000)>n)
                                  {
                                                   System.out.println((int)Math.abs((i*1000)-n));
                                                   break;
                                  }
                                  } if(i*1000==n){System.out.println(0);break;} i*1000==n i*1000 i 1000 n {System.out.println(0);break;} System.out.println(0) System.out.println System.out System System.out 0 break; if((i*1000)>n)
                                  {
                                                   System.out.println((int)Math.abs((i*1000)-n));
                                                   break;
                                  } (i*1000)>n (i*1000) i 1000 n {
                                                   System.out.println((int)Math.abs((i*1000)-n));
                                                   break;
                                  } System.out.println((int)Math.abs((i*1000)-n)) System.out.println System.out System System.out (int)Math.abs((i*1000)-n) Math.abs Math (i*1000)-n (i*1000) i 1000 n break; String[] args args public class Main {

                 public static void main(String[] args) {
                                  Scanner ob = new Scanner(System.in);

                                  int n = ob.nextInt();
                                  for(int i=1;i<1000;i++)
                                  {
                                  if(i*1000==n){System.out.println(0);break;}
                                  if((i*1000)>n)
                                  {
                                                   System.out.println((int)Math.abs((i*1000)-n));
                                                   break;
                                  }
                                  }
                              //    System.out.println((int)Math.abs(n-1000));
                 }

} public class Main {

                 public static void main(String[] args) {
                                  Scanner ob = new Scanner(System.in);

                                  int n = ob.nextInt();
                                  for(int i=1;i<1000;i++)
                                  {
                                  if(i*1000==n){System.out.println(0);break;}
                                  if((i*1000)>n)
                                  {
                                                   System.out.println((int)Math.abs((i*1000)-n));
                                                   break;
                                  }
                                  }
                              //    System.out.println((int)Math.abs(n-1000));
                 }

} Main
import java.util.Scanner;

public class Main {

                 public static void main(String[] args) {
                                  Scanner ob = new Scanner(System.in);

                                  int n = ob.nextInt();
                                  for(int i=1;i<1000;i++)
                                  {
                                  if(i*1000==n){System.out.println(0);break;}
                                  if((i*1000)>n)
                                  {
                                                   System.out.println((int)Math.abs((i*1000)-n));
                                                   break;
                                  }
                                  }
                              //    System.out.println((int)Math.abs(n-1000));
                 }

}
