import java.util.Scanner;

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

        int rest = 0;
        int senyen = 0;
        if(n % 1000 == 0) {
            senyen = n % 1000;
            System.out.println(senyen);
        } else {
            rest = n % 1000;
            System.out.println(1000 - rest);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int rest = 0;
        int senyen = 0;
        if(n % 1000 == 0) {
            senyen = n % 1000;
            System.out.println(senyen);
        } else {
            rest = n % 1000;
            System.out.println(1000 - rest);
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int rest = 0;
        int senyen = 0;
        if(n % 1000 == 0) {
            senyen = n % 1000;
            System.out.println(senyen);
        } else {
            rest = n % 1000;
            System.out.println(1000 - rest);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int rest = 0;
        int senyen = 0;
        if(n % 1000 == 0) {
            senyen = n % 1000;
            System.out.println(senyen);
        } else {
            rest = n % 1000;
            System.out.println(1000 - rest);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int rest = 0; rest 0 int senyen = 0; senyen 0 if(n % 1000 == 0) {
            senyen = n % 1000;
            System.out.println(senyen);
        } else {
            rest = n % 1000;
            System.out.println(1000 - rest);
        } n % 1000 == 0 n % 1000 n 1000 0 {
            senyen = n % 1000;
            System.out.println(senyen);
        } senyen = n % 1000 senyen n % 1000 n 1000 System.out.println(senyen) System.out.println System.out System System.out senyen {
            rest = n % 1000;
            System.out.println(1000 - rest);
        } rest = n % 1000 rest n % 1000 n 1000 System.out.println(1000 - rest) System.out.println System.out System System.out 1000 - rest 1000 rest String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int rest = 0;
        int senyen = 0;
        if(n % 1000 == 0) {
            senyen = n % 1000;
            System.out.println(senyen);
        } else {
            rest = n % 1000;
            System.out.println(1000 - rest);
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int rest = 0;
        int senyen = 0;
        if(n % 1000 == 0) {
            senyen = n % 1000;
            System.out.println(senyen);
        } else {
            rest = n % 1000;
            System.out.println(1000 - rest);
        }
    }
} Main
import java.util.Scanner;

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

        int rest = 0;
        int senyen = 0;
        if(n % 1000 == 0) {
            senyen = n % 1000;
            System.out.println(senyen);
        } else {
            rest = n % 1000;
            System.out.println(1000 - rest);
        }
    }
}
