#include using namespace std; using ll = long long; using P = pair; #define rep(i,n) for(int i=0;i> n >> k; int ans = n; if (k>0 && k<=n){ if (n%2==0) ans -= 2; else if ((n+1)/2==k) ans--; else ans -= 2; } else ans = 0; cout << ans << endl; return 0; }