import java.util.*;
import java.io.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	
		int n = sc.nextInt();
		int pay = 0;
		while(pay < n){
			pay += 1000;
		}

		n = pay - n;
		System.out.println(n);
	}
} import java.util.*; util.* java import java.io.*; io.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	
		int n = sc.nextInt();
		int pay = 0;
		while(pay < n){
			pay += 1000;
		}

		n = pay - n;
		System.out.println(n);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	
		int n = sc.nextInt();
		int pay = 0;
		while(pay < n){
			pay += 1000;
		}

		n = pay - n;
		System.out.println(n);
	} main {
		Scanner sc = new Scanner(System.in);
	
		int n = sc.nextInt();
		int pay = 0;
		while(pay < n){
			pay += 1000;
		}

		n = pay - n;
		System.out.println(n);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int pay = 0; pay 0 while(pay < n){
			pay += 1000;
		} pay < n pay n {
			pay += 1000;
		} pay += 1000 pay 1000 n = pay - n n pay - n pay n System.out.println(n) System.out.println System.out System System.out n String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	
		int n = sc.nextInt();
		int pay = 0;
		while(pay < n){
			pay += 1000;
		}

		n = pay - n;
		System.out.println(n);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	
		int n = sc.nextInt();
		int pay = 0;
		while(pay < n){
			pay += 1000;
		}

		n = pay - n;
		System.out.println(n);
	}
} Main
import java.util.*;
import java.io.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	
		int n = sc.nextInt();
		int pay = 0;
		while(pay < n){
			pay += 1000;
		}

		n = pay - n;
		System.out.println(n);
	}
}