#pragma GCC optimize("O3", "unroll-loops") #include using namespace std; #define ll long long int main(void){ int N, K; cin >> N >> K; if (N % 2 == 0) cout << min(K + 1, N / 2) << endl; else cout << min(K + 1, N) << endl; return 0; }