import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        while(N>0){
            N-=1000;
        }
        System.out.println(N*-1);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        while(N>0){
            N-=1000;
        }
        System.out.println(N*-1);
    }
} Main public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        while(N>0){
            N-=1000;
        }
        System.out.println(N*-1);
    } main {
        // Your code here!
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        while(N>0){
            N-=1000;
        }
        System.out.println(N*-1);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc while(N>0){
            N-=1000;
        } N>0 N 0 {
            N-=1000;
        } N-=1000 N 1000 System.out.println(N*-1) System.out.println System.out System System.out N*-1 N -1 1 String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        while(N>0){
            N-=1000;
        }
        System.out.println(N*-1);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        while(N>0){
            N-=1000;
        }
        System.out.println(N*-1);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        while(N>0){
            N-=1000;
        }
        System.out.println(N*-1);
    }
}