import java.util.Scanner;
 
public class Main {
   public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
      
      int N = sc.nextInt();
     
      for(int i=0; i<1000; i++) {
        int cal = 1000 * i - N;
        if(cal >= 0) {
          System.out.println(cal);
          break;
        } else {
          continue;
        }
      }
   }
} import java.util.Scanner; Scanner java.util public class Main {
   public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
      
      int N = sc.nextInt();
     
      for(int i=0; i<1000; i++) {
        int cal = 1000 * i - N;
        if(cal >= 0) {
          System.out.println(cal);
          break;
        } else {
          continue;
        }
      }
   }
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
      
      int N = sc.nextInt();
     
      for(int i=0; i<1000; i++) {
        int cal = 1000 * i - N;
        if(cal >= 0) {
          System.out.println(cal);
          break;
        } else {
          continue;
        }
      }
   } main {
		Scanner sc = new Scanner(System.in);
      
      int N = sc.nextInt();
     
      for(int i=0; i<1000; i++) {
        int cal = 1000 * i - N;
        if(cal >= 0) {
          System.out.println(cal);
          break;
        } else {
          continue;
        }
      }
   } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc for(int i=0; i<1000; i++) {
        int cal = 1000 * i - N;
        if(cal >= 0) {
          System.out.println(cal);
          break;
        } else {
          continue;
        }
      } int i=0; int i=0; i 0 i<1000 i 1000 i++ i++ i {
        int cal = 1000 * i - N;
        if(cal >= 0) {
          System.out.println(cal);
          break;
        } else {
          continue;
        }
      } {
        int cal = 1000 * i - N;
        if(cal >= 0) {
          System.out.println(cal);
          break;
        } else {
          continue;
        }
      } int cal = 1000 * i - N; cal 1000 * i - N 1000 * i 1000 i N if(cal >= 0) {
          System.out.println(cal);
          break;
        } else {
          continue;
        } cal >= 0 cal 0 {
          System.out.println(cal);
          break;
        } System.out.println(cal) System.out.println System.out System System.out cal break; {
          continue;
        } continue; String[] args args public class Main {
   public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
      
      int N = sc.nextInt();
     
      for(int i=0; i<1000; i++) {
        int cal = 1000 * i - N;
        if(cal >= 0) {
          System.out.println(cal);
          break;
        } else {
          continue;
        }
      }
   }
} public class Main {
   public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
      
      int N = sc.nextInt();
     
      for(int i=0; i<1000; i++) {
        int cal = 1000 * i - N;
        if(cal >= 0) {
          System.out.println(cal);
          break;
        } else {
          continue;
        }
      }
   }
} Main
import java.util.Scanner;
 
public class Main {
   public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
      
      int N = sc.nextInt();
     
      for(int i=0; i<1000; i++) {
        int cal = 1000 * i - N;
        if(cal >= 0) {
          System.out.println(cal);
          break;
        } else {
          continue;
        }
      }
   }
}