Problem: It's been long after the events of the previous problems, and Karen has now moved on from student life and is looking to relocate to a new neighborhood.

<image>

The neighborhood consists of n houses in a straight line, labelled 1 to n from left to right, all an equal distance apart.

Everyone in this neighborhood loves peace and quiet. Because of this, whenever a new person moves into the neighborhood, he or she always chooses the house whose minimum distance to any occupied house is maximized. If there are multiple houses with the maximum possible minimum distance, he or she chooses the leftmost one.

Note that the first person to arrive always moves into house 1.

Karen is the k-th person to enter this neighborhood. If everyone, including herself, follows this rule, which house will she move into?

Input

The first and only line of input contains two integers, n and k (1 ≤ k ≤ n ≤ 1018), describing the number of houses in the neighborhood, and that Karen was the k-th person to move in, respectively.

Output

Output a single integer on a line by itself, the label of the house Karen will move into.

Examples

Input

6 4


Output

2


Input

39 3


Output

20

Note

In the first test case, there are 6 houses in the neighborhood, and Karen is the fourth person to move in:

  1. The first person moves into house 1. 
  2. The second person moves into house 6. 
  3. The third person moves into house 3. 
  4. The fourth person moves into house 2. 



In the second test case, there are 39 houses in the neighborhood, and Karen is the third person to move in:

  1. The first person moves into house 1. 
  2. The second person moves into house 39. 
  3. The third person moves into house 20. 

Solution (in JAVA):

Solution:
import java.util.*;

/**
 * Created by zhengyanglzy on 2017/6/24.
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            long houseNum = sc.nextLong();
            long k = sc.nextLong();
            System.out.println(cal(houseNum, k));
        }
    }
    
    static long cal(long houseNum, long k) {
        if (k == 1) {
            return 1;

        } else if (k == 2) {
            return houseNum;
        }
        return 1 + findLabel(houseNum - 2, k - 2);
    }

    static long findLabel(long houseNum, long k) {
        // System.out.printf("%d %d\n", houseNum, k);
        long medium = (houseNum + 1) / 2;
        if (k == 1) {
            return medium;
        }
        k -= 1;
        Part leftPart = new Part(medium - 1);
        Part rightPart = new Part(houseNum - medium);
        long leftTotal = 0;
        long rightTotal = 0;
        while (true) {
            long left = leftPart.peek();
            long right = rightPart.peek();
            if (left == 0 && right == 0) {
                break;
            }
            if (k > left + right) {
                k -= left + right;
                leftTotal += left;
                rightTotal += right;
                leftPart.split();
                rightPart.split();
                continue;
            }
            leftPart.collapse();
            rightPart.collapse();
            TreeSet<Long> set = new TreeSet<Long>();
            set.addAll(leftPart.segs.keySet());
            set.addAll(rightPart.segs.keySet());
            for (long len : set.descendingSet()) {
                if (leftPart.segs.containsKey(len)) {
                    if (leftPart.segs.get(len) >= k) {
                        return findLabel(medium - 1, leftTotal + k);
                    } else {
                        k -= leftPart.segs.get(len);
                        leftTotal += leftPart.segs.get(len);
                    }
                }
                if (rightPart.segs.containsKey(len)) {
                    if (rightPart.segs.get(len) >= k) {
                        return medium + findLabel(houseNum - medium, rightTotal + k);
                    } else {
                        k -= rightPart.segs.get(len);
                        rightTotal += rightPart.segs.get(len);
                    }
                }
            }
        }
        // 只剩1和2
        if (medium - 1 - leftTotal >= k) {
            return findLabel(medium - 1, leftTotal + k);
        }
        return medium + findLabel(houseNum - medium, rightTotal + k - (medium - 1 - leftTotal));
    }

    static class Part {
        Map<Long, Long> segs;

        Part(long num) {
            segs = new HashMap<Long, Long>();
            segs.put(num, 1L);
        }

        void split() {
            Map<Long, Long> newMap = new HashMap<Long, Long>();
            for (Map.Entry<Long, Long> entry : segs.entrySet()) {
                if (entry.getKey() <= 2) {
                    update(newMap, entry.getKey(), entry.getValue());
                    continue;
                }
                long medium = (entry.getKey() + 1) / 2;
                update(newMap, medium - 1, entry.getValue());
                update(newMap, entry.getKey() - medium, entry.getValue());
            }
            segs = newMap;
        }

        long peek() {
            long ret = 0;
            for (Map.Entry<Long, Long> entry : segs.entrySet()) {
                if (entry.getKey() > 2) {
                    ret += entry.getValue();
                }
            }
            return ret;
        }

        void collapse() {
            Map<Long, Long> newMap = new HashMap<Long, Long>();
            for (Map.Entry<Long, Long> entry : segs.entrySet()) {
                update(newMap, (entry.getKey() + 1) / 2, entry.getValue());
            }
            segs = newMap;
        }

        static void update(Map<Long, Long> map, long key, long inc) {
            if (!map.containsKey(key)) {
                map.put(key, 0L);
            }
            map.put(key, map.get(key) + inc);
        }
    }

    static class Seg implements Comparable<Seg> {
        int start;
        int length;

        public Seg(int start, int length) {
            this.start = start;
            this.length = length;
        }

        public int compareTo(Seg o) {
            int diff = (length - 1) / 2 - (o.length -1) / 2;
            if (diff != 0) {
                return -diff;
            }
            return start - o.start;
        }
    }
}