function main(input) {
  const n = parseInt(input[0]);
  if(n%1000===0){
    console.log(0);
  }else{
    console.log(1000-(n%1000));
  }
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));