#include <bits/stdc++.h>
using namespace std;
long long n, k;
bool read() {
  if (scanf("%lld%lld", &n, &k) < 2) {
    return 0;
  }
  return 1;
}
vector<long long> generate(long long len) {
  vector<long long> res;
  set<long long> S;
  S.insert(len);
  while (!S.empty()) {
    long long cur = *S.rbegin();
    S.erase(cur);
    res.push_back(cur);
    if (!cur) {
      break;
    }
    S.insert((cur - 1) / 2);
    S.insert(cur / 2);
  }
  sort(begin(res), end(res));
  sort(begin(res), end(res)),
      res.resize(unique(begin(res), end(res)) - res.begin());
  return res;
}
vector<int> left_len;
vector<int> right_len;
vector<long long> lens;
vector<vector<long long> > dp;
long long get_cnt(int id, int min_left_len) {
  if (left_len[id] == min_left_len) {
    return 1;
  }
  if (left_len[id] < min_left_len) {
    return 0;
  }
  long long& ans = dp[id][min_left_len];
  if (ans != -1) {
    return ans;
  }
  ans = 0;
  ans += get_cnt(left_len[id], min_left_len);
  ans += get_cnt(right_len[id], min_left_len);
  return ans;
}
long long get_mid_pos(int id, long long k, int min_left_len) {
  assert(k);
  assert(left_len[id] >= min_left_len);
  if (left_len[id] == min_left_len) {
    return lens[min_left_len];
  }
  const long long left_cnt = get_cnt(left_len[id], min_left_len);
  if (left_cnt >= k) {
    return get_mid_pos(left_len[id], k, min_left_len);
  }
  k -= left_cnt;
  return lens[left_len[id]] + 1 + get_mid_pos(right_len[id], k, min_left_len);
}
long long get_cnt2(int id) {
  if (lens[id] == 0) {
    return 0;
  }
  if (lens[id] == 1) {
    return 1;
  }
  if (lens[id] == 2) {
    return 2;
  }
  long long& ans = dp[id][0];
  if (ans != -1) {
    return ans;
  }
  ans = 0;
  ans += get_cnt2(left_len[id]);
  ans += get_cnt2(right_len[id]);
  return ans;
}
long long get_mid_pos2(int id, long long k) {
  assert(k);
  assert(lens[id] > 0);
  if (lens[id] == 1) {
    assert(k == 1);
    return 0;
  }
  if (lens[id] == 2) {
    if (k == 1) {
      return 0;
    }
    if (k == 2) {
      return 1;
    }
    assert(0);
  }
  const long long left_cnt = get_cnt2(left_len[id]);
  if (left_cnt >= k) {
    return get_mid_pos2(left_len[id], k);
  }
  k -= left_cnt;
  return lens[left_len[id]] + 1 + get_mid_pos2(right_len[id], k);
}
int get_pos_len(long long len) {
  const int pos = lower_bound(begin(lens), end(lens), len) - lens.begin();
  assert(pos < ((int)(lens).size()) && lens[pos] == len);
  return pos;
}
long long solve() {
  if (k == 1) {
    return 1;
  }
  if (k == 2) {
    return n;
  }
  k -= 2;
  lens = generate(n - 2);
  left_len.resize(((int)(lens).size()));
  right_len.resize(((int)(lens).size()));
  for (int i = 0; i < int(((int)(lens).size())); ++i) {
    left_len[i] = get_pos_len((lens[i] - 1) / 2);
    right_len[i] = get_pos_len(lens[i] / 2);
  }
  dp.clear();
  dp.resize(((int)(lens).size()), vector<long long>(((int)(lens).size()), -1));
  vector<long long> coef(((int)(lens).size()), 0);
  coef.back() = 1;
  for (int i = ((int)(lens).size()) - 1; i >= 0;) {
    int j = i;
    while (j >= 0 && left_len[j] == left_len[i]) {
      --j;
    }
    long long sum_coef = 0;
    for (int z = j + 1; z <= i; ++z) {
      sum_coef += coef[z];
    }
    if (lens[i] == 2) {
      long long pos = get_mid_pos2(((int)(lens).size()) - 1, k);
      return pos + 2;
    }
    if (sum_coef < k) {
      k -= sum_coef;
      for (int z = j + 1; z <= i; ++z) {
        coef[left_len[z]] += coef[z];
        coef[right_len[z]] += coef[z];
        coef[z] = 0;
      }
      i = j;
      continue;
    }
    long long pos = get_mid_pos(((int)(lens).size()) - 1, k, left_len[i]);
    return pos + 2;
  }
  assert(0);
  return -1;
}
int main() {
  while (read()) {
    cout << solve() << "\n";
  }
  return 0;
}
