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