#include #define int long long #define double long double using namespace std; const int MOD = 1000000007; const int INF = 1e14; using Graph = vector>; signed main(){ int L, K; cin >> L >> K; int ans = L/(2*K)*K; if( L%(2*K) == 0 ) ans -= K; cout << ans << endl; }