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);



	}
}

/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz