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