import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();

		int money=0;

		while(true){
			money+=1000;
			if(money>=A){
				break;
			}
		}

		System.out.println(money-A);


	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();

		int money=0;

		while(true){
			money+=1000;
			if(money>=A){
				break;
			}
		}

		System.out.println(money-A);


	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();

		int money=0;

		while(true){
			money+=1000;
			if(money>=A){
				break;
			}
		}

		System.out.println(money-A);


	} main {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();

		int money=0;

		while(true){
			money+=1000;
			if(money>=A){
				break;
			}
		}

		System.out.println(money-A);


	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int A = scan.nextInt(); A scan.nextInt() scan.nextInt scan int money=0; money 0 while(true){
			money+=1000;
			if(money>=A){
				break;
			}
		} true {
			money+=1000;
			if(money>=A){
				break;
			}
		} money+=1000 money 1000 if(money>=A){
				break;
			} money>=A money A {
				break;
			} break; System.out.println(money-A) System.out.println System.out System System.out money-A money A String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();

		int money=0;

		while(true){
			money+=1000;
			if(money>=A){
				break;
			}
		}

		System.out.println(money-A);


	}

} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();

		int money=0;

		while(true){
			money+=1000;
			if(money>=A){
				break;
			}
		}

		System.out.println(money-A);


	}

} Main
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();

		int money=0;

		while(true){
			money+=1000;
			if(money>=A){
				break;
			}
		}

		System.out.println(money-A);


	}

}
