# No.128 お年玉(1) n, m = [int(input()) for i in range(2)] amount = 0 while n - (amount + 1000) * m >= 0: amount += 1000 print(amount)