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