#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << '{';
  for (int i = (0), __i = (((int)(vec).size())); i < __i; i++) {
    os << vec[i];
    if (i + 1 != ((int)(vec).size())) os << ',';
  }
  os << '}';
  return os;
}
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &par) {
  os << '(' << par.first << ',' << par.second << ')';
  return os;
}
int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
template <class T>
T sqr(T x) {
  return x * x;
}
int main() {
  ios::sync_with_stdio(false);
  long long n, k, N, K;
  cin >> N >> K;
  n = N;
  k = K;
  if (k == 1) {
    cout << 1 << endl;
    return 0;
  } else if (k == 2) {
    cout << n << endl;
    return 0;
  }
  n -= 2;
  k -= 2;
  long long d = 1, d1, d2, d21, mn, mx, mnx, n1, n2, res = 0;
  while (k > d && n / d > 2) {
    n -= d;
    k -= d;
    d *= 2;
  }
  mn = n / d;
  mx = mn + (n > mn * d);
  mnx = mn + mx;
  n2 = n - d * mn;
  n1 = d - n2;
  if (n2 > d / 2) {
    d1 = 0;
    d2 = d - 2 * (n2 - d / 2);
  } else {
    d1 = d - 2 * n2;
    d2 = d;
  }
  d21 = (d2 - d1) / 2;
  if (mx <= 2) {
    while (d > 1) {
      if (k > n / 2) {
        res += d / 2 + n / 2;
        k -= n / 2;
        n2 -= n2 / 2;
        n -= n / 2;
      } else {
        n2 /= 2;
        n /= 2;
      }
      d /= 2;
    }
    res += 1 + k;
  } else if (mn & 1) {
    while (d > 1) {
      if (k > d / 2) {
        res += d / 2 + n / 2;
        k -= d / 2;
        n2 -= n2 / 2;
        n -= n / 2;
      } else {
        n2 /= 2;
        n /= 2;
      }
      d /= 2;
    }
    res += 1 + ((n2 == 1) ? (mx + 1) / 2 : (mn + 1) / 2);
  } else {
    if (k <= n2) {
      while (d > 1) {
        if (k > n2 / 2) {
          res += d / 2 + n / 2;
          k -= n2 / 2;
          n2 -= n2 / 2;
          n -= n / 2;
        } else {
          n2 /= 2;
          n /= 2;
        }
        d /= 2;
      }
      res += 1 + (mx + 1) / 2;
    } else {
      k -= n2;
      if (mn == 2) {
        while (d > 1) {
          if (k > n / 2 - n2 / 2) {
            res += d / 2 + n / 2;
            k -= n / 2 - n2 / 2;
            n2 -= n2 / 2;
            n -= n / 2;
          } else {
            n2 /= 2;
            n /= 2;
          }
          d /= 2;
        }
        if (n2 == 1)
          res += k * 2;
        else
          res += 1 + k;
      } else {
        while (d > 1) {
          if (k > (n1 + 1) / 2) {
            res += d / 2 + n / 2;
            k -= (n1 + 1) / 2;
            n2 -= n2 / 2;
            n -= n / 2;
          } else {
            n2 /= 2;
            n /= 2;
          }
          d /= 2;
          n1 = d - n2;
        }
        res += 1 + (mn + 1) / 2;
      }
    }
  }
  cout << res << endl;
  return 0;
}
