import java.util.Scanner;
import java.io.IOException;

public class Main {
	public static void main(String[] args) throws IOException{
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		for(;num > 1000;) {
			num -= 1000;
		}
		System.out.println(1000-num);
	}
} import java.util.Scanner; Scanner java.util import java.io.IOException; IOException java.io public class Main {
	public static void main(String[] args) throws IOException{
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		for(;num > 1000;) {
			num -= 1000;
		}
		System.out.println(1000-num);
	}
} Main public static void main(String[] args) throws IOException{
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		for(;num > 1000;) {
			num -= 1000;
		}
		System.out.println(1000-num);
	} main {
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		for(;num > 1000;) {
			num -= 1000;
		}
		System.out.println(1000-num);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int num = scan.nextInt(); num scan.nextInt() scan.nextInt scan for(;num > 1000;) {
			num -= 1000;
		} ; num > 1000 num 1000 {
			num -= 1000;
		} {
			num -= 1000;
		} num -= 1000 num 1000 System.out.println(1000-num) System.out.println System.out System System.out 1000-num 1000 num String[] args args public class Main {
	public static void main(String[] args) throws IOException{
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		for(;num > 1000;) {
			num -= 1000;
		}
		System.out.println(1000-num);
	}
} public class Main {
	public static void main(String[] args) throws IOException{
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		for(;num > 1000;) {
			num -= 1000;
		}
		System.out.println(1000-num);
	}
} Main
import java.util.Scanner;
import java.io.IOException;

public class Main {
	public static void main(String[] args) throws IOException{
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		for(;num > 1000;) {
			num -= 1000;
		}
		System.out.println(1000-num);
	}
}