function main(input) {

    let a = input;
    
    for (let i = 1000; i <= 10000; i+=1000) {
        if (i - a  >= 0) {
            console.log(i - a);
            break;
        }
    }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
