"use strict"
function main(arg) {
    let N = arg.trim().split("\n")[0]
    for (let i = 1;; i++) {
        if (N <= i * 1000 ) {
            // console.log(i)
            console.log(i*1000 - N)
            break
        }
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));