import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int payment = sc.nextInt();
        int yen = 1000;
        while(yen<payment){
            yen = yen + 1000;
        }
        System.out.println(yen - payment);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int payment = sc.nextInt();
        int yen = 1000;
        while(yen<payment){
            yen = yen + 1000;
        }
        System.out.println(yen - payment);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int payment = sc.nextInt();
        int yen = 1000;
        while(yen<payment){
            yen = yen + 1000;
        }
        System.out.println(yen - payment);
    } main {
        Scanner sc = new Scanner(System.in);
        int payment = sc.nextInt();
        int yen = 1000;
        while(yen<payment){
            yen = yen + 1000;
        }
        System.out.println(yen - payment);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int payment = sc.nextInt(); payment sc.nextInt() sc.nextInt sc int yen = 1000; yen 1000 while(yen<payment){
            yen = yen + 1000;
        } yen<payment yen payment {
            yen = yen + 1000;
        } yen = yen + 1000 yen yen + 1000 yen 1000 System.out.println(yen - payment) System.out.println System.out System System.out yen - payment yen payment String[] args args public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int payment = sc.nextInt();
        int yen = 1000;
        while(yen<payment){
            yen = yen + 1000;
        }
        System.out.println(yen - payment);
    }
} public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int payment = sc.nextInt();
        int yen = 1000;
        while(yen<payment){
            yen = yen + 1000;
        }
        System.out.println(yen - payment);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int payment = sc.nextInt();
        int yen = 1000;
        while(yen<payment){
            yen = yen + 1000;
        }
        System.out.println(yen - payment);
    }
}