import java.util.Scanner;
public class Main {
     public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        sc.close();
        int s = 0;
        for(int i=1000;  s<a; i+=1000){
             s = i;
        }
        System.out.println(s-a);
    }
} import java.util.Scanner; Scanner java.util public class Main {
     public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        sc.close();
        int s = 0;
        for(int i=1000;  s<a; i+=1000){
             s = i;
        }
        System.out.println(s-a);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        sc.close();
        int s = 0;
        for(int i=1000;  s<a; i+=1000){
             s = i;
        }
        System.out.println(s-a);
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        sc.close();
        int s = 0;
        for(int i=1000;  s<a; i+=1000){
             s = i;
        }
        System.out.println(s-a);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc sc.close() sc.close sc int s = 0; s 0 for(int i=1000;  s<a; i+=1000){
             s = i;
        } int i=1000; int i=1000; i 1000 s<a s a i+=1000 i+=1000 i 1000 {
             s = i;
        } {
             s = i;
        } s = i s i System.out.println(s-a) System.out.println System.out System System.out s-a s a String[] args args public class Main {
     public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        sc.close();
        int s = 0;
        for(int i=1000;  s<a; i+=1000){
             s = i;
        }
        System.out.println(s-a);
    }
} public class Main {
     public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        sc.close();
        int s = 0;
        for(int i=1000;  s<a; i+=1000){
             s = i;
        }
        System.out.println(s-a);
    }
} Main
import java.util.Scanner;
public class Main {
     public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        sc.close();
        int s = 0;
        for(int i=1000;  s<a; i+=1000){
             s = i;
        }
        System.out.println(s-a);
    }
}