#include using namespace std; int main(){ int a,b;cin>>a>>b; if(a%(b*2)){ cout << a/(b*2)*b << endl; }else{ cout << (a/(b*2)-1)*b << endl; } }