l, k = map(int, input().strip().split()) ly = 0 lh = 0 while l>0: if l > 2*k: l = l - 2*k ly += k lh += k elif l > k: l = l -k lh += k else: l = 0 lh += l print(ly)