N = int(input()) #予算
M = int(input()) #子どもの人数

#均等に1000円札で最大となるように配分

if N / M < 1000:
    print(0)
elif N / M >= 1000:
    x = N // M
    print(round(x, -3) - 1000)