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