


import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        System.out.println(n % 1000 > 0 ? 1000 - n % 1000 : 0);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        System.out.println(n % 1000 > 0 ? 1000 - n % 1000 : 0);
    }
} Main public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        System.out.println(n % 1000 > 0 ? 1000 - n % 1000 : 0);
    } main {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        System.out.println(n % 1000 > 0 ? 1000 - n % 1000 : 0);
    } Scanner input = new Scanner(System.in); input new Scanner(System.in) int n = input.nextInt(); n input.nextInt() input.nextInt input System.out.println(n % 1000 > 0 ? 1000 - n % 1000 : 0) System.out.println System.out System System.out n % 1000 > 0 ? 1000 - n % 1000 : 0 n % 1000 > 0 n % 1000 n 1000 0 1000 - n % 1000 1000 n % 1000 n 1000 0 String[] args args public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        System.out.println(n % 1000 > 0 ? 1000 - n % 1000 : 0);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        System.out.println(n % 1000 > 0 ? 1000 - n % 1000 : 0);
    }
} Main



import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        System.out.println(n % 1000 > 0 ? 1000 - n % 1000 : 0);
    }
}