function main(arg) {
  let a = parseInt(arg, 10);
  let counter = 0;
  while (true) {
    counter = counter + 1000;
    if (a <= counter) {
      console.log(counter - a);
      break;
    }
  }
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
// main(`3000`);
// https://atcoder.jp/contests/abc173/tasks/abc173_a
