L, K = (int(i) for i in input().split()) ans = (L // (K*2)) * K if L % (K*2) == 0: ans -= K print(ans)