N = int(input()) M = int(input()) print(N//M - (N//M)%1000)