fun main(){

    val input = readLine()!!.toInt()

    var a: Int = input / 1000

    var b = input - (a*1000)

    when(b){
        0 -> {
            println(0)
        }
        else ->{
            println(1000 - b)
        }
    }
}