import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc=  new Scanner(System.in);

        int num = sc.nextInt();

        float f = num/1000f;

        int l = (int)(Math.ceil(f));
        System.out.println(l*1000-num);
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {

        Scanner sc=  new Scanner(System.in);

        int num = sc.nextInt();

        float f = num/1000f;

        int l = (int)(Math.ceil(f));
        System.out.println(l*1000-num);
    }
} Main public static void main(String[] args) {

        Scanner sc=  new Scanner(System.in);

        int num = sc.nextInt();

        float f = num/1000f;

        int l = (int)(Math.ceil(f));
        System.out.println(l*1000-num);
    } main {

        Scanner sc=  new Scanner(System.in);

        int num = sc.nextInt();

        float f = num/1000f;

        int l = (int)(Math.ceil(f));
        System.out.println(l*1000-num);
    } Scanner sc=  new Scanner(System.in); sc new Scanner(System.in) int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc float f = num/1000f; f num/1000f num 1000f int l = (int)(Math.ceil(f)); l (int)(Math.ceil(f)) Math.ceil Math f System.out.println(l*1000-num) System.out.println System.out System System.out l*1000-num l*1000 l 1000 num String[] args args public class Main {

    public static void main(String[] args) {

        Scanner sc=  new Scanner(System.in);

        int num = sc.nextInt();

        float f = num/1000f;

        int l = (int)(Math.ceil(f));
        System.out.println(l*1000-num);
    }
} public class Main {

    public static void main(String[] args) {

        Scanner sc=  new Scanner(System.in);

        int num = sc.nextInt();

        float f = num/1000f;

        int l = (int)(Math.ceil(f));
        System.out.println(l*1000-num);
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc=  new Scanner(System.in);

        int num = sc.nextInt();

        float f = num/1000f;

        int l = (int)(Math.ceil(f));
        System.out.println(l*1000-num);
    }
}
