fun main(args: Array<String>) {
    val n = readInt()
    var m = 1000
    while (m < n) {
        m += 1000
    }
    println(m-n)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()