#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ii = pair<int, int>;
using vi = vector<int>;
constexpr int N = 5010, INF = 1000000010;
ll n, k;
ll solve(ll n, ll k) {
  ll sl = (n - 1) / 2, sr = n / 2;
  if (k == 0) return sl;
  k -= 1;
  priority_queue<pair<ll, pair<ll, int>>> q;
  map<ll, ll, greater<ll>> ml{{(n - 1) / 2, 1}}, mr{{n / 2, 1}};
  ll lc = 0, rc = 0;
  while (true) {
    auto itl = ml.begin(), itr = mr.begin();
    if (itl->first > 0 && (itl->first - 1) / 2 >= (itr->first - 1) / 2) {
      if (k < itl->second) return solve(sl, lc + k);
      lc += itl->second;
      k -= itl->second;
      ml[(itl->first - 1) / 2] += itl->second;
      ml[itl->first / 2] += itl->second;
      ml.erase(itl);
    } else {
      if (k < itr->second) return sl + 1 + solve(sr, rc + k);
      rc += itr->second;
      k -= itr->second;
      mr[(itr->first - 1) / 2] += itr->second;
      mr[itr->first / 2] += itr->second;
      mr.erase(itr);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20);
  cin >> n >> k;
  if (k == 1)
    cout << 1;
  else if (k == 2)
    cout << n;
  else {
    n -= 2;
    k -= 3;
    cout << 2 + solve(n, k);
  }
}
