function Main(inputs) {
	const inputline = inputs.split("\n");
	let price = parseInt(inputline[0], 10);
  	while(price > 1000){
      price -= 1000;
    }
	let change = 1000 - price;
  
	console.log(change);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));