#include <bits/stdc++.h>
using namespace std;
unsigned long long findLevel(unsigned long long N, unsigned long long n) {
  unsigned long long curLevel = 0;
  unsigned long long add2 = 1;
  unsigned long long placed = 0;
  while (placed < n) {
    placed += add2;
    add2 = add2 * 2;
    curLevel++;
  }
  return curLevel - 1;
}
bool cruelCase(unsigned long long N, unsigned long long n) {
  unsigned long long curSCnt = 1;
  unsigned long long curBCnt = 0;
  unsigned long long SLen = N;
  unsigned long long add2 = 1;
  unsigned long long placed = 0;
  while (SLen > 3) {
    if (SLen % 2 == 1) {
      curBCnt = curBCnt * 2 + curSCnt;
      curSCnt = curSCnt;
    } else {
      curSCnt = curSCnt * 2 + curBCnt;
      curBCnt = curBCnt;
    }
    SLen = SLen / 2;
    placed += add2;
    add2 *= 2;
  }
  if (SLen == 3 && placed + curBCnt < n) return 1;
  if (SLen != 3 && placed < n) return 1;
  return 0;
}
unsigned long long cruelLevelCnt(unsigned long long N, unsigned long long n) {
  unsigned long long curSCnt = 1;
  unsigned long long curBCnt = 0;
  unsigned long long SLen = N;
  unsigned long long add2 = 1;
  unsigned long long placed = 0;
  while (SLen > 3) {
    if (SLen % 2 == 1) {
      curBCnt = curBCnt * 2 + curSCnt;
      curSCnt = curSCnt;
    } else {
      curSCnt = curSCnt * 2 + curBCnt;
      curBCnt = curBCnt;
    }
    SLen = SLen / 2;
    placed += add2;
    add2 *= 2;
  }
  if (SLen == 3) return n - placed - curBCnt;
  return n - placed;
}
unsigned long long cruelCnt(unsigned long long len) {
  unsigned long long curSCnt = 1;
  unsigned long long curBCnt = 0;
  unsigned long long SLen = len;
  unsigned long long add2 = 1;
  unsigned long long placed = 0;
  while (SLen > 3) {
    if (SLen % 2 == 1) {
      curBCnt = curBCnt * 2 + curSCnt;
      curSCnt = curSCnt;
    } else {
      curSCnt = curSCnt * 2 + curBCnt;
      curBCnt = curBCnt;
    }
    SLen = SLen / 2;
    placed += add2;
    add2 *= 2;
  }
  if (SLen == 3) return len - 1 - placed - curBCnt;
  return len - 1 - placed;
}
unsigned long long findLevelCnt(unsigned long long level,
                                unsigned long long n) {
  unsigned long long curLevel = 0;
  unsigned long long add2 = 1;
  unsigned long long cnt = 0;
  while (curLevel < level) {
    cnt += add2;
    add2 = add2 * 2;
    curLevel += 1;
  }
  return n - cnt;
}
unsigned long long cntBOnLvl(unsigned long long len, bool isBig,
                             unsigned long long curLvl,
                             unsigned long long onLvl) {
  unsigned long long curSCnt = !isBig;
  unsigned long long curBCnt = isBig;
  unsigned long long SLen = len - (isBig);
  unsigned long long ans = isBig && (len % 1 == 0);
  while (curLvl < onLvl) {
    if (SLen % 2 == 1) {
      curBCnt = curBCnt * 2 + curSCnt;
      curSCnt = curSCnt;
    } else {
      curSCnt = curSCnt * 2 + curBCnt;
      curBCnt = curBCnt;
    }
    SLen = SLen / 2;
    curLvl++;
  }
  if (SLen % 2 == 1)
    return curBCnt;
  else
    return 0;
}
unsigned long long cntSOnLvl(unsigned long long len, bool isBig,
                             unsigned long long curLvl,
                             unsigned long long onLvl) {
  unsigned long long curSCnt = !isBig;
  unsigned long long curBCnt = isBig;
  unsigned long long SLen = len - (isBig);
  unsigned long long ans = isBig && (len % 1 == 0);
  while (curLvl < onLvl) {
    if (SLen % 2 == 1) {
      curBCnt = (curBCnt * 2) + curSCnt;
      curSCnt = curSCnt;
    } else {
      curSCnt = curSCnt * 2 + curBCnt;
      curBCnt = curBCnt;
    }
    SLen = SLen / 2;
    curLvl++;
  }
  if (SLen % 2 == 1)
    return curSCnt;
  else
    return curSCnt + curBCnt;
}
unsigned long long findSol(unsigned long long N, unsigned long long n) {
  unsigned long long level = findLevel(N, n);
  unsigned long long levelCnt = findLevelCnt(level, n);
  unsigned long long levelfBCnt = cntBOnLvl(N, false, 0, level);
  unsigned long long left = 0;
  unsigned long long right = N;
  if (cruelCase(N, n)) {
    long long lvl = 0;
    levelCnt = cruelLevelCnt(N, n);
    while (right - left > 3) {
      lvl++;
      unsigned long long leftLen = (right - left) / 2;
      unsigned long long rightLen = (right - left) - (right - left) / 2;
      unsigned long long leftCnt = cruelCnt(leftLen);
      unsigned long long rigthCnt = cruelCnt(rightLen);
      if (leftCnt < levelCnt) {
        levelCnt = levelCnt - leftCnt;
        left = left + (right - left) / 2;
      } else {
        levelCnt = levelCnt;
        right = left + (right - left) / 2;
      }
    }
    return left + levelCnt + 1;
  } else {
    if (levelfBCnt >= levelCnt) {
      unsigned long long curLvl = 0;
      unsigned long long curS = (right - left);
      while (curLvl < level) {
        curLvl++;
        curS = curS / 2;
        unsigned long long leftLen = (right - left) / 2;
        unsigned long long rightLen = (right - left) - (right - left) / 2;
        unsigned long long leftFB =
            cntBOnLvl(leftLen, leftLen != curS, curLvl, level);
        unsigned long long rightFB =
            cntBOnLvl(rightLen, rightLen != curS, curLvl, level);
        if (leftFB < levelCnt) {
          levelCnt = levelCnt - leftFB;
          left = left + (right - left) / 2;
        } else {
          levelCnt = levelCnt;
          right = left + (right - left) / 2;
        }
      }
    } else {
      levelCnt = levelCnt - levelfBCnt;
      unsigned long long curLvl = 0;
      unsigned long long curS = (right - left);
      while (curLvl < level) {
        curLvl++;
        curS = curS / 2;
        unsigned long long leftLen = (right - left) / 2;
        unsigned long long rightLen = (right - left) - (right - left) / 2;
        unsigned long long leftS =
            cntSOnLvl(leftLen, leftLen != curS, curLvl, level);
        unsigned long long rightS =
            cntSOnLvl(rightLen, rightLen != curS, curLvl, level);
        if (leftS < levelCnt) {
          levelCnt = levelCnt - leftS;
          left = left + (right - left) / 2;
        } else {
          levelCnt = levelCnt;
          right = left + (right - left) / 2;
        }
      }
    }
    return left + (right - left) / 2 + 1;
  }
}
int main() {
  unsigned long long N;
  unsigned long long n;
  cin >> N >> n;
  if (n == 1) {
    cout << 1;
    return 0;
  }
  if (n == 2) {
    cout << N;
    return 0;
  }
  n = n - 2;
  N = N - 1;
  cout << findSol(N, n) << endl;
  return 0;
}
