"use strict";

const main = arg => {
    if((arg % 1000) === 0) {
        console.log(0)
    } else {
     console.log(1000 - (arg % 1000))   
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  