import java.util.Scanner

import scala.collection.mutable.ArrayBuffer

object Main {

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()

    val i = n / 1000
    val ans = (i + 1) * 1000 - n

    println(ans)

  }
}
