function Main(input) {
	input = input.split("\n");
	
	var n = parseInt(input[0], 10);
	
	var result = 10000 - n
	for (var i = 1; i < 11; i++) {
	if  (result < 1000) {
	break;
	} else {
	result = result - 1000;
	}
	}
	
	console.log(result);
	}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));