"use strict";

function main(input) {
  input = input.trim();
  let N = parseInt(input);
  let ans;
  let i = 1000;
  while (true) {
    if (i - N >= 0) {
      ans = i - N;
      break;
    }
    i = i + 1000;
  }
  console.log(ans);
}

function numberSort(array) {
  array.sort(f);
  return array;
}

var f = function (a, b) {
  return a - b;
};

main(require("fs").readFileSync("/dev/stdin", "utf-8"));
