#cording: utf-8 l, k = map(int, input().split()) s = 0 while True: s = s + k if (l-s*2) <= 0: break s = s - k print(s)