#include using namespace std; using ll = long long; constexpr char newl = '\n'; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n, k; cin >> n >> k; if (n & 1) { cout << min(n, k + 1) << newl; } else { cout << min(n / 2, k + 1) << newl; } return 0; }