We will buy a product for N yen (the currency of Japan) at a shop.  If we use only 1000-yen bills to pay the price, how much change will we receive?  Assume we use the minimum number of bills required.
N=int(input())

if N>=10000:
    print(N-10000)
elif N>=9000:
    print(N-9000)
elif N>=8000:
    print(N-8000)
elif N>=7000:
    print(N-7000)
elif N>=6000:
    print(N-6000)
elif N>=5000:
    print(N-5000)
elif N>=4000:
    print(N-4000)
elif N>=3000:
    print(N-3000)
elif N>=2000:
    print(N-2000)
elif N>=1000:
    print(N-1000)
else:
    print(N)
N=int(input())

if N==10000:
    print(0)
elif N>9000:
    print(10000-N)
elif N>8000:
    print(9000-N)
elif N>7000:
    print(8000-N)
elif N>6000:
    print(7000-N)
elif N>5000:
    print(6000-N)
elif N>4000:
    print(5000-N)
elif N>3000:
    print(4000-N)
elif N>2000:
    print(3000-N)
elif N>1000:
    print(2000-N)
else:
    print(1000-N)