import scala.math.floor

object Main extends App {

  def change(input: Int) = {
    var firstInt = 0
    if(input % 1000 == 0) {
      firstInt = floor(input / 1000).toInt
    } else {
      firstInt = floor(input / 1000).toInt + 1
    }
  
    val money = firstInt * 1000
    println(money - input)
  }
}