#include using namespace std; typedef long long int ll; ll mod = 1000000007; ll r(ll x, ll y) { if (y == 0) return 1; else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod; else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod; } int main() { ll n, k; cin >> n>> k; if (n % 2 == 0) { if (k % 2 == 0) { k /= 2; ll sum = 1; sum += (2 * k); if (sum > n / 2) { sum = n / 2; } printf("%lld\n", sum); } else { k = k / 2; ll sum = 2; sum += (2 * k); if (sum > n / 2) { sum = n / 2; } printf("%lld\n", sum); } } else { if (k % 2 == 0) { k /= 2; ll sum = 1; sum += (2 * k); if (sum > n) { sum = n; } printf("%lld\n", sum); } else { k = k / 2; ll sum = 2; sum += (2 * k); if (sum > n) { sum = n; } printf("%lld\n", sum); } } }