function Main(input) {

	input = input.split("\n");
        let payPrice = parseInt(input[0], 10); //数値に変換
       while (payPrice > 1000){ 
             payPrice = payPrice - 1000;
       }

       let change = 1000 - payPrice;

	//結果出力
	console.log(change);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
