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