const main = async () => {
  const input = require('fs').readFileSync('/dev/stdin', 'UTF-8').trim()

const num = parseInt(input).toLocaleString().split(',')
const answer = 1000 - parseInt(num[num.length - 1])

if (answer === 1000) {
  console.log('1000');

} else {
  console.log(answer);

}
}

main()