n = int(input())
m = int(input())

max_total = n // m
result = (max_total // 1000) * 1000
print(result)