const main = (input) => {
  const change = (answer) => {
    const temp = parseInt(answer, 10);
    if (temp === 0) {
      return 0;
    } else {
      return 1000 - temp;
    }
  };

  const N = input.trim().split("");
  if (N.length <= 3) {
    console.log(change(N.join("")));
  } else {
    let answer = "";
    let cnt = 0;

    while (cnt < 3) {
      answer = N.pop() + answer;
      cnt++;
    }

    console.log(change(answer));
  }
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));