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