L, K = map(int, input().split()) Yu = L // (2 * K) * K if Yu == L / 2: Yu -= K print(Yu)