
Imports System.Console
Module Module1
    Dim n As Integer
    Sub Main()
        n = ReadLine()
        If n Mod 1000 = 0 Then
            WriteLine("0")
        Else
            WriteLine(1000 - (n Mod 1000))
        End If
    End Sub
End Module
