#include #include #include #include #include #include #include #include #include #include using namespace std; #ifdef _WIN32 #include #endif int main() { int n, k; cin >> n >> k; if ((n == 1) || (k == 0 || k > n)) cout << 0 << endl; else if ((n%2) && (k == (n+1)/2)) cout << n - 1 << endl; else cout << n - 2 << endl; }