num=input()
if int(num)<=1000:
    change=1000-int(num)
else:
    array_1=list(num)
    array_1=array_1[-4:]
    a=''.join(array_1)
    b=int(array_1[-4])+1
    pay=b*1000
    change=pay-int(a)
    if array_1[-1]=="0" and array_1[-2]=="0" and array_1[-3]=="0":
        change=0
print(change)