L, K = map(int, input().split()) dm = divmod(L, K*2) if dm[1] == 0: dm[0] -= 1 print(dm[0] * K)