// let input = "3000";

function main(input){
  input = input.trim();
  input = parseInt(input);
  let amari = input%1000;
  let answer;
  
  if(amari===0){
    answer = 0;
  }else{
    answer = 1000 - amari;
  }
  console.log(answer);
}
main(require("fs").readFileSync("/dev/stdin","utf8"));
