import java.util.*;

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

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