const main = async () => {
  const input = require('fs').readFileSync('/dev/stdin', 'UTF-8').trim()
  const n = input
  const bill = 1000
  const mod = n % bill
  const change = (bill - mod) % bill
  
  console.log(change)
}

main()