#include "bits/stdc++.h" using namespace std; #define fastcin {\ cin.tie(0);\ ios::sync_with_stdio(false);\ } #define rep(i, a, b) for(int i = a; i < b; i++) #define rrep(i, a, b) for(int i = a; i >= b; i--) #define fore(i, a) for(auto &i:a) #define print(x) cout << x << "\n" #define SORT(a, n) sort(a, a+n); #define REVERSE(a,n) reverse(a,a+n); #define VSORT(v) sort(v.begin(), v.end()); #define VREVERSE(v) reverse(v.begin(), v.end()); #define MOD 1000000007 #define yes "YES" #define no "NO" using ll = long long; using vi = vector; using vvi = vector; using vll = vector; ll combination(int n,int r) { ll i = 1; int k = r > n - r ? n - r : r, count; if(k < 0) return 0; std::list list; std::list::iterator it; for(count = 2; count <= k; ++count) list.push_back(count); for(count = n; count > n - k; --count) { i *= count; for(it = list.begin(); it != list.end(); ) { if(!(i % *it)) { i /= *it; it = list.erase(it); } else ++it; } } return i; } int main() { fastcin; int n, k, ans = 0; cin >> n >> k; if(k == 0 || k > n); else if(n < 3); else if(n&1 && n/2==k-1) ans = n-1; else ans = n-2; print(ans); return 0; }