let main = (input) => {
    let usrInput = parseInt(input)
    let value = usrInput % 1000
    if (value === 0) {
        console.log(0)
    }
    else {
        console.log(1000 - value)
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))