import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        int pien=1000;
        int otsuri=0;
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int amari = N%pien;
        if(amari != 0){
             otsuri = pien-amari;
        }else{
            otsuri = amari;
        }
        System.out.println(otsuri);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        int pien=1000;
        int otsuri=0;
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int amari = N%pien;
        if(amari != 0){
             otsuri = pien-amari;
        }else{
            otsuri = amari;
        }
        System.out.println(otsuri);
    }
} Main public static void main(String[] args) throws Exception {
        int pien=1000;
        int otsuri=0;
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int amari = N%pien;
        if(amari != 0){
             otsuri = pien-amari;
        }else{
            otsuri = amari;
        }
        System.out.println(otsuri);
    } main {
        int pien=1000;
        int otsuri=0;
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int amari = N%pien;
        if(amari != 0){
             otsuri = pien-amari;
        }else{
            otsuri = amari;
        }
        System.out.println(otsuri);
    } int pien=1000; pien 1000 int otsuri=0; otsuri 0 Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner int amari = N%pien; amari N%pien N pien if(amari != 0){
             otsuri = pien-amari;
        }else{
            otsuri = amari;
        } amari != 0 amari 0 {
             otsuri = pien-amari;
        } otsuri = pien-amari otsuri pien-amari pien amari {
            otsuri = amari;
        } otsuri = amari otsuri amari System.out.println(otsuri) System.out.println System.out System System.out otsuri String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        int pien=1000;
        int otsuri=0;
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int amari = N%pien;
        if(amari != 0){
             otsuri = pien-amari;
        }else{
            otsuri = amari;
        }
        System.out.println(otsuri);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        int pien=1000;
        int otsuri=0;
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int amari = N%pien;
        if(amari != 0){
             otsuri = pien-amari;
        }else{
            otsuri = amari;
        }
        System.out.println(otsuri);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        int pien=1000;
        int otsuri=0;
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int amari = N%pien;
        if(amari != 0){
             otsuri = pien-amari;
        }else{
            otsuri = amari;
        }
        System.out.println(otsuri);
    }
}
