#include <bits/stdc++.h>
using namespace std;
map<long long, long long> m2;
long long go(long long now, long long targ) {
  if (now == 0LL) {
    return 0LL;
  }
  if (m2.find(now) != m2.end()) {
    return m2[now];
  }
  long long ret = 0LL;
  long long half = now / 2LL;
  long long other = now - 1LL - half;
  long long space = (now - 1LL) / 2LL;
  if (space == targ) {
    ret++;
  }
  ret += go(half, targ);
  ret += go(other, targ);
  m2[now] = ret;
  return ret;
}
long long go2(long long now, long long rem, long long targ) {
  if (now == 0) {
    return 0LL;
  }
  long long half = now / 2LL;
  long long other = now - 1LL - half;
  long long space = (now - 1LL) / 2LL;
  if (space == targ && rem == 1) {
    return (now / 2LL) + (now % 2LL);
  }
  if (space == targ) {
    rem--;
  }
  if (other > 0 && m2[other] >= rem) {
    return go2(other, rem, targ);
  } else {
    return other + 1LL + go2(half, rem - m2[other], targ);
  }
}
int main() {
  long long n, k;
  cin >> n >> k;
  if (k == 1) {
    cout << 1 << endl;
    return 0;
  }
  if (k == 2) {
    cout << n << endl;
    return 0;
  }
  n -= 2;
  k -= 2;
  map<long long, long long> m1;
  deque<long long> li1;
  m1[n] = 1LL;
  li1.push_back(n);
  long long val = -1;
  long long ind = -1;
  long long freq = 0LL;
  long long last = -1LL;
  while (li1.size() != 0) {
    long long now = li1.front();
    li1.pop_front();
    long long size = m1[now];
    if (size == 0) {
      continue;
    }
    long long half = now / 2LL;
    long long other = now - 1LL - half;
    long long space = (now - 1LL) / 2LL;
    if (now == 0LL) {
      last = 0LL;
    }
    if (space != last || now == 0LL) {
      if (freq >= k) {
        ind = k;
        val = last;
        break;
      } else {
        k -= freq;
        freq = 0;
      }
      last = space;
    }
    freq += size;
    if (m1.find(half) == m1.end()) {
      m1[half] = 0LL;
    }
    if (m1.find(other) == m1.end()) {
      m1[other] = 0LL;
    }
    m1[half] = m1[half] + size;
    m1[other] = m1[other] + size;
    m1[now] = 0LL;
    li1.push_back(half);
    li1.push_back(other);
  }
  m2[0LL] = 0LL;
  go(n, val);
  long long ans = (1LL + go2(n, ind, val));
  cout << ans << endl;
  return 0;
}
