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