#include <bits/stdc++.h>
using namespace std;
long long N, K;
long long s1, s2, p1, p2;
long long Get(long long now, long long to) {
  if (now <= to << 1) return 0;
  long long re = 0;
  s1 = 1;
  s2 = 0;
  p1 = now;
  p2 = now - 1;
  while (p2 >= to << 1) {
    if (p2 == to << 1) return s1 + re;
    if (p1 & 1) {
      re += s1 + s2;
      s1 = (s1 << 1) + s2;
    } else {
      re += s1 + s2;
      s2 = (s2 << 1) + s1;
    }
    p2 = (p1 >> 1) - 1;
    p1 = (p1 >> 1);
  }
  return re;
}
long long solve(long long l, long long r, long long p, long long k) {
  long long mid = (l + r) >> 1;
  if (k == 1) return mid;
  long long tmp = Get(mid - l, p), Tmp = Get(r - mid, p + 1);
  if (k > tmp + Tmp + 1)
    return solve(mid + 1, r, p, k - tmp - 1);
  else
    return solve(l, mid - 1, p, k - Tmp - 1);
}
int main() {
  scanf("%lld%lld", &N, &K);
  if (K == 1) {
    printf("1");
    return 0;
  }
  if (K == 2) {
    printf("%lld", N);
    return 0;
  }
  N -= 2;
  K -= 2;
  long long l = 0, r = (N >> 1) + 1;
  while (r - l > 1) {
    long long mid = (l + r) >> 1;
    if (Get(N, mid) < K)
      r = mid;
    else
      l = mid;
  }
  printf("%lld", solve(1, N, l, K) + 1);
}
