import java.util.Scanner;

public class Main {

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

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

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

	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		int N=scanner.nextInt();
		int change= (1000-(N%1000));
		if (N%1000==0) {
			System.out.println("0");
		}else {
			System.out.println(change);
		}
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		int N=scanner.nextInt();
		int change= (1000-(N%1000));
		if (N%1000==0) {
			System.out.println("0");
		}else {
			System.out.println(change);
		}
	}
}
