#include #define rep(i,n) for(int i=0; i<(n); i++) using namespace std; typedef long long ll; int main(){ int L,K; cin>>L>>K; if(L%(2*K)==0){ cout << (L/(2*K)-1)*K << endl;; } else { cout << (L/(2*K))*K << endl; } }