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