function main(lines) {
  const N = +lines[0];
  
  let res;
  
  for (let i = 1000; i <= 10000; i += 1000) {
    if (i >= N) {
      res = i - N;
      break;
    }
  }
  
  console.log(res);
}


main( require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n") );



function splitN(s) {
  return s.split(' ').map(Number);
}
