#include using namespace std; int main() { int L, K; cin >> L >> K; if (L % (K * 2) == 0) { cout << ((L / (K * 2)) - 1) * K << endl; return 0; } cout << (L / (K * 2)) * K << endl; return 0; }