import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int N  = Integer.parseInt(s.nextLine());
        int num = 1000 - N%1000;
        if (num == 1000){
            System.out.println(0);
        } else {
            System.out.println(num);
        }

//        int W  = Integer.parseInt(s.nextLine());
//        int K  = Integer.parseInt(s.nextLine());
        }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int N  = Integer.parseInt(s.nextLine());
        int num = 1000 - N%1000;
        if (num == 1000){
            System.out.println(0);
        } else {
            System.out.println(num);
        }

//        int W  = Integer.parseInt(s.nextLine());
//        int K  = Integer.parseInt(s.nextLine());
        }
} Main public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int N  = Integer.parseInt(s.nextLine());
        int num = 1000 - N%1000;
        if (num == 1000){
            System.out.println(0);
        } else {
            System.out.println(num);
        }

//        int W  = Integer.parseInt(s.nextLine());
//        int K  = Integer.parseInt(s.nextLine());
        } main {
        Scanner s = new Scanner(System.in);
        int N  = Integer.parseInt(s.nextLine());
        int num = 1000 - N%1000;
        if (num == 1000){
            System.out.println(0);
        } else {
            System.out.println(num);
        }

//        int W  = Integer.parseInt(s.nextLine());
//        int K  = Integer.parseInt(s.nextLine());
        } Scanner s = new Scanner(System.in); s new Scanner(System.in) int N  = Integer.parseInt(s.nextLine()); N Integer.parseInt(s.nextLine()) Integer.parseInt Integer s.nextLine() s.nextLine s int num = 1000 - N%1000; num 1000 - N%1000 1000 N%1000 N 1000 if (num == 1000){
            System.out.println(0);
        } else {
            System.out.println(num);
        } num == 1000 num 1000 {
            System.out.println(0);
        } System.out.println(0) System.out.println System.out System System.out 0 {
            System.out.println(num);
        } System.out.println(num) System.out.println System.out System System.out num String[] args args public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int N  = Integer.parseInt(s.nextLine());
        int num = 1000 - N%1000;
        if (num == 1000){
            System.out.println(0);
        } else {
            System.out.println(num);
        }

//        int W  = Integer.parseInt(s.nextLine());
//        int K  = Integer.parseInt(s.nextLine());
        }
} public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int N  = Integer.parseInt(s.nextLine());
        int num = 1000 - N%1000;
        if (num == 1000){
            System.out.println(0);
        } else {
            System.out.println(num);
        }

//        int W  = Integer.parseInt(s.nextLine());
//        int K  = Integer.parseInt(s.nextLine());
        }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int N  = Integer.parseInt(s.nextLine());
        int num = 1000 - N%1000;
        if (num == 1000){
            System.out.println(0);
        } else {
            System.out.println(num);
        }

//        int W  = Integer.parseInt(s.nextLine());
//        int K  = Integer.parseInt(s.nextLine());
        }
}