/**
 * A
 */
import java.io.*;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        InputStream in = System.in;
        Scanner scanner = new Scanner(in);
    
        int next = scanner.nextInt();
        int left = 1000 - (next % 1000);
        System.out.println(left == 1000 ? 0 : left);
        scanner.close();
    }

} import java.io.*; io.* java import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        InputStream in = System.in;
        Scanner scanner = new Scanner(in);
    
        int next = scanner.nextInt();
        int left = 1000 - (next % 1000);
        System.out.println(left == 1000 ? 0 : left);
        scanner.close();
    }

} Main public static void main(String[] args) {
        InputStream in = System.in;
        Scanner scanner = new Scanner(in);
    
        int next = scanner.nextInt();
        int left = 1000 - (next % 1000);
        System.out.println(left == 1000 ? 0 : left);
        scanner.close();
    } main {
        InputStream in = System.in;
        Scanner scanner = new Scanner(in);
    
        int next = scanner.nextInt();
        int left = 1000 - (next % 1000);
        System.out.println(left == 1000 ? 0 : left);
        scanner.close();
    } InputStream in = System.in; in System.in System System.in Scanner scanner = new Scanner(in); scanner new Scanner(in) int next = scanner.nextInt(); next scanner.nextInt() scanner.nextInt scanner int left = 1000 - (next % 1000); left 1000 - (next % 1000) 1000 (next % 1000) next 1000 System.out.println(left == 1000 ? 0 : left) System.out.println System.out System System.out left == 1000 ? 0 : left left == 1000 left 1000 0 left scanner.close() scanner.close scanner String[] args args public class Main {
    public static void main(String[] args) {
        InputStream in = System.in;
        Scanner scanner = new Scanner(in);
    
        int next = scanner.nextInt();
        int left = 1000 - (next % 1000);
        System.out.println(left == 1000 ? 0 : left);
        scanner.close();
    }

} public class Main {
    public static void main(String[] args) {
        InputStream in = System.in;
        Scanner scanner = new Scanner(in);
    
        int next = scanner.nextInt();
        int left = 1000 - (next % 1000);
        System.out.println(left == 1000 ? 0 : left);
        scanner.close();
    }

} Main
/**
 * A
 */
import java.io.*;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        InputStream in = System.in;
        Scanner scanner = new Scanner(in);
    
        int next = scanner.nextInt();
        int left = 1000 - (next % 1000);
        System.out.println(left == 1000 ? 0 : left);
        scanner.close();
    }

}