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