const main = (input) => {
  const s = parseInt(input.trim(), 10)
  let m = 0
  while (s > m) {
    m += 1000
  }

  return  console.log(m - s)
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))