fun main(args: Array<String>) {
    when(val n = readLine()!!.toInt()) {
       in 1..1000 -> {
           println(1000 -n)
       }
        in 1001..2000 -> {
            println(2000 -n)
        }
        in 2001..3000 -> {
            println(3000 -n)
        }
        in 3001..4000 -> {
            println(4000 -n)
        }
        in 4001..5000 -> {
            println(5000 -n)
        }
        in 5001..6000 -> {
            println(6000 -n)
        }
        in 6001..7000 -> {
            println(7000 -n)
        }
        in 7001..8000 -> {
            println(8000 -n)
        }
        in 8001..9000 -> {
            println(9000 -n)
        }
        in 9001..10000 -> {
            println(10000 -n)
        }
    }
}