#include using namespace std; int main(){ int N, K; cin >> N >> K; if (N % 2 == 0){ cout << min(N / 2, K + 1) << endl; } else { cout << min(N, K + 1) << endl; } }