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