import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int input = sc.nextInt();

        while (input > 1000) {
            input -= 1000;
        }
      
        if (input == 0)
            System.out.println(0);
        else {
            int res = 1000-input;
            System.out.println(res);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int input = sc.nextInt();

        while (input > 1000) {
            input -= 1000;
        }
      
        if (input == 0)
            System.out.println(0);
        else {
            int res = 1000-input;
            System.out.println(res);
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int input = sc.nextInt();

        while (input > 1000) {
            input -= 1000;
        }
      
        if (input == 0)
            System.out.println(0);
        else {
            int res = 1000-input;
            System.out.println(res);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        int input = sc.nextInt();

        while (input > 1000) {
            input -= 1000;
        }
      
        if (input == 0)
            System.out.println(0);
        else {
            int res = 1000-input;
            System.out.println(res);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int input = sc.nextInt(); input sc.nextInt() sc.nextInt sc while (input > 1000) {
            input -= 1000;
        } input > 1000 input 1000 {
            input -= 1000;
        } input -= 1000 input 1000 if (input == 0)
            System.out.println(0);
        else {
            int res = 1000-input;
            System.out.println(res);
        } input == 0 input 0 System.out.println(0) System.out.println System.out System System.out 0 {
            int res = 1000-input;
            System.out.println(res);
        } int res = 1000-input; res 1000-input 1000 input System.out.println(res) System.out.println System.out System System.out res String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int input = sc.nextInt();

        while (input > 1000) {
            input -= 1000;
        }
      
        if (input == 0)
            System.out.println(0);
        else {
            int res = 1000-input;
            System.out.println(res);
        }
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int input = sc.nextInt();

        while (input > 1000) {
            input -= 1000;
        }
      
        if (input == 0)
            System.out.println(0);
        else {
            int res = 1000-input;
            System.out.println(res);
        }
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int input = sc.nextInt();

        while (input > 1000) {
            input -= 1000;
        }
      
        if (input == 0)
            System.out.println(0);
        else {
            int res = 1000-input;
            System.out.println(res);
        }
    }
}
