import java.util.Scanner;

/**
 * コンソールテスト用Main クラス
 *
 */
public class Main {

	/* コンストラクタ */
	Main() {
	//何もしない
	}

	/**
	 * 提出
	 *
	 */

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int sen = 1000;
		int otsuri = 0;
		int kisuu = 0;
		int shiharai = 0;
		int ichiman = 10000;
		int waru =  0;

		if (n <= sen) {
			otsuri = sen - n;
		} else {
			if (n == ichiman) {
				//何もしない

			} else {
				waru = n % sen;
				kisuu = n /sen;
				if (waru != 0) {
					shiharai = kisuu * sen + sen;
					otsuri = shiharai - n;
				} else {
					shiharai = kisuu * sen ;
					otsuri = shiharai - n;			
				}
			}
		}

		System.out.println(otsuri);



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

	/* コンストラクタ */
	Main() {
	//何もしない
	}

	/**
	 * 提出
	 *
	 */

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int sen = 1000;
		int otsuri = 0;
		int kisuu = 0;
		int shiharai = 0;
		int ichiman = 10000;
		int waru =  0;

		if (n <= sen) {
			otsuri = sen - n;
		} else {
			if (n == ichiman) {
				//何もしない

			} else {
				waru = n % sen;
				kisuu = n /sen;
				if (waru != 0) {
					shiharai = kisuu * sen + sen;
					otsuri = shiharai - n;
				} else {
					shiharai = kisuu * sen ;
					otsuri = shiharai - n;			
				}
			}
		}

		System.out.println(otsuri);



	}
} Main /* コンストラクタ */
	Main() {
	//何もしない
	} Main {
	//何もしない
	} /**
	 * 提出
	 *
	 */

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int sen = 1000;
		int otsuri = 0;
		int kisuu = 0;
		int shiharai = 0;
		int ichiman = 10000;
		int waru =  0;

		if (n <= sen) {
			otsuri = sen - n;
		} else {
			if (n == ichiman) {
				//何もしない

			} else {
				waru = n % sen;
				kisuu = n /sen;
				if (waru != 0) {
					shiharai = kisuu * sen + sen;
					otsuri = shiharai - n;
				} else {
					shiharai = kisuu * sen ;
					otsuri = shiharai - n;			
				}
			}
		}

		System.out.println(otsuri);



	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int sen = 1000;
		int otsuri = 0;
		int kisuu = 0;
		int shiharai = 0;
		int ichiman = 10000;
		int waru =  0;

		if (n <= sen) {
			otsuri = sen - n;
		} else {
			if (n == ichiman) {
				//何もしない

			} else {
				waru = n % sen;
				kisuu = n /sen;
				if (waru != 0) {
					shiharai = kisuu * sen + sen;
					otsuri = shiharai - n;
				} else {
					shiharai = kisuu * sen ;
					otsuri = shiharai - n;			
				}
			}
		}

		System.out.println(otsuri);



	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int sen = 1000; sen 1000 int otsuri = 0; otsuri 0 int kisuu = 0; kisuu 0 int shiharai = 0; shiharai 0 int ichiman = 10000; ichiman 10000 int waru =  0; waru 0 if (n <= sen) {
			otsuri = sen - n;
		} else {
			if (n == ichiman) {
				//何もしない

			} else {
				waru = n % sen;
				kisuu = n /sen;
				if (waru != 0) {
					shiharai = kisuu * sen + sen;
					otsuri = shiharai - n;
				} else {
					shiharai = kisuu * sen ;
					otsuri = shiharai - n;			
				}
			}
		} n <= sen n sen {
			otsuri = sen - n;
		} otsuri = sen - n otsuri sen - n sen n {
			if (n == ichiman) {
				//何もしない

			} else {
				waru = n % sen;
				kisuu = n /sen;
				if (waru != 0) {
					shiharai = kisuu * sen + sen;
					otsuri = shiharai - n;
				} else {
					shiharai = kisuu * sen ;
					otsuri = shiharai - n;			
				}
			}
		} if (n == ichiman) {
				//何もしない

			} else {
				waru = n % sen;
				kisuu = n /sen;
				if (waru != 0) {
					shiharai = kisuu * sen + sen;
					otsuri = shiharai - n;
				} else {
					shiharai = kisuu * sen ;
					otsuri = shiharai - n;			
				}
			} n == ichiman n ichiman {
				//何もしない

			} {
				waru = n % sen;
				kisuu = n /sen;
				if (waru != 0) {
					shiharai = kisuu * sen + sen;
					otsuri = shiharai - n;
				} else {
					shiharai = kisuu * sen ;
					otsuri = shiharai - n;			
				}
			} waru = n % sen waru n % sen n sen kisuu = n /sen kisuu n /sen n sen if (waru != 0) {
					shiharai = kisuu * sen + sen;
					otsuri = shiharai - n;
				} else {
					shiharai = kisuu * sen ;
					otsuri = shiharai - n;			
				} waru != 0 waru 0 {
					shiharai = kisuu * sen + sen;
					otsuri = shiharai - n;
				} shiharai = kisuu * sen + sen shiharai kisuu * sen + sen kisuu * sen kisuu sen sen otsuri = shiharai - n otsuri shiharai - n shiharai n {
					shiharai = kisuu * sen ;
					otsuri = shiharai - n;			
				} shiharai = kisuu * sen shiharai kisuu * sen kisuu sen otsuri = shiharai - n otsuri shiharai - n shiharai n System.out.println(otsuri) System.out.println System.out System System.out otsuri String args[] args public class Main {

	/* コンストラクタ */
	Main() {
	//何もしない
	}

	/**
	 * 提出
	 *
	 */

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int sen = 1000;
		int otsuri = 0;
		int kisuu = 0;
		int shiharai = 0;
		int ichiman = 10000;
		int waru =  0;

		if (n <= sen) {
			otsuri = sen - n;
		} else {
			if (n == ichiman) {
				//何もしない

			} else {
				waru = n % sen;
				kisuu = n /sen;
				if (waru != 0) {
					shiharai = kisuu * sen + sen;
					otsuri = shiharai - n;
				} else {
					shiharai = kisuu * sen ;
					otsuri = shiharai - n;			
				}
			}
		}

		System.out.println(otsuri);



	}
} public class Main {

	/* コンストラクタ */
	Main() {
	//何もしない
	}

	/**
	 * 提出
	 *
	 */

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int sen = 1000;
		int otsuri = 0;
		int kisuu = 0;
		int shiharai = 0;
		int ichiman = 10000;
		int waru =  0;

		if (n <= sen) {
			otsuri = sen - n;
		} else {
			if (n == ichiman) {
				//何もしない

			} else {
				waru = n % sen;
				kisuu = n /sen;
				if (waru != 0) {
					shiharai = kisuu * sen + sen;
					otsuri = shiharai - n;
				} else {
					shiharai = kisuu * sen ;
					otsuri = shiharai - n;			
				}
			}
		}

		System.out.println(otsuri);



	}
} Main
import java.util.Scanner;

/**
 * コンソールテスト用Main クラス
 *
 */
public class Main {

	/* コンストラクタ */
	Main() {
	//何もしない
	}

	/**
	 * 提出
	 *
	 */

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int sen = 1000;
		int otsuri = 0;
		int kisuu = 0;
		int shiharai = 0;
		int ichiman = 10000;
		int waru =  0;

		if (n <= sen) {
			otsuri = sen - n;
		} else {
			if (n == ichiman) {
				//何もしない

			} else {
				waru = n % sen;
				kisuu = n /sen;
				if (waru != 0) {
					shiharai = kisuu * sen + sen;
					otsuri = shiharai - n;
				} else {
					shiharai = kisuu * sen ;
					otsuri = shiharai - n;			
				}
			}
		}

		System.out.println(otsuri);



	}
}
