def main(str)
  x = str.to_i % 1000
  x > 0 ? 1000 - x : 0
end

unless ENV["TEST"]
  puts(main($stdin.read.chomp))
  exit(0)
end

require 'minitest/autorun'

class TestA < Minitest::Test
  def test_main
    assert_equal(100, main("1900"))
    assert_equal(0, main("3000"))
  end
end


