#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
inline bool smin(T &a, const T &b) {
  return a > b ? a = b : a;
}
template <typename T>
inline bool smax(T &a, const T &b) {
  return a < b ? a = b : a;
}
const long long N = (long long)505, mod = (long long)0;
set<long long> values;
long long contain[N][N];
long long gd(long long first) { return (first + 1) / 2; }
int32_t main() {
  long long n, num;
  cin >> n >> num;
  if (num == 1) {
    cout << 1 << endl;
    return 0;
  }
  if (num == 2) {
    cout << n << endl;
    return 0;
  }
  n -= 2;
  num -= 2;
  values.insert(n);
  for (long long turn = 0; turn < 100; ++turn) {
    for (long long first : values)
      if (first >= 1) {
        values.insert(gd(first) - 1);
        values.insert(first - gd(first));
      }
  }
  vector<long long> all;
  for (long long first : values) all.push_back(first);
  vector<long long> dv;
  long long sz = (long long)all.size();
  sort(all.begin(), all.end());
  reverse(all.begin(), all.end());
  for (long long first : all) dv.push_back(gd(first));
  sort((dv).begin(), (dv).end());
  dv.resize(unique((dv).begin(), (dv).end()) - dv.begin());
  reverse(dv.begin(), dv.end());
  long long dsz = (long long)dv.size();
  map<long long, long long> rev;
  for (long long j = 0; j < dsz; ++j) rev[dv[j]] = j;
  map<long long, long long> pl;
  for (long long j = 0; j < (long long)all.size(); ++j) pl[all[j]] = j;
  for (long long j = sz - 1; j >= 0; --j) {
    long long first = all[j];
    contain[j][rev[gd(first)]] = 1;
    for (long long k = 0; k < sz; ++k)
      contain[j][k] +=
          contain[pl[gd(first) - 1]][k] + contain[pl[first - gd(first)]][k];
  }
  long long house = 0, dist = -1;
  long long tmp = num;
  for (long long j = 0; j < dsz; ++j) {
    tmp -= contain[0][j];
    if (tmp <= 0) {
      dist = dv[j];
      tmp += contain[0][j];
      break;
    }
  }
  if (dist == -1) assert(0);
  num = tmp - 1;
  long long size = n;
  while (true) {
    if (gd(size) == dist) --num;
    if (num == -1 && gd(size) == dist) {
      cout << house + gd(size) + 1 << endl;
      return 0;
    }
    if (size == -1) break;
    if (num < contain[pl[gd(size) - 1]][rev[dist]]) {
      size = gd(size) - 1;
    } else {
      num -= contain[pl[gd(size) - 1]][rev[dist]];
      house += gd(size);
      size = size - gd(size);
    }
  }
}
