import java.util.Scanner;

public class Main {

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int exchange = 1000*((N-1)/1000+1)-N;
		System.out.println(exchange);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int exchange = 1000*((N-1)/1000+1)-N;
		System.out.println(exchange);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int exchange = 1000*((N-1)/1000+1)-N;
		System.out.println(exchange);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int exchange = 1000*((N-1)/1000+1)-N; exchange 1000*((N-1)/1000+1)-N 1000*((N-1)/1000+1) 1000 ((N-1)/1000+1) (N-1)/1000 (N-1) N 1 1000 1 N System.out.println(exchange) System.out.println System.out System System.out exchange String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int exchange = 1000*((N-1)/1000+1)-N;
		System.out.println(exchange);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int exchange = 1000*((N-1)/1000+1)-N;
		System.out.println(exchange);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int exchange = 1000*((N-1)/1000+1)-N;
		System.out.println(exchange);
	}
}
