Amr bought a new video game "Guess Your Way Out!". The goal of the game is to find an exit from the maze that looks like a perfect binary tree of height h. The player is initially standing at the root of the tree and the exit from the tree is located at some leaf node. 

Let's index all the leaf nodes from the left to the right from 1 to 2h. The exit is located at some node n where 1 ≤ n ≤ 2h, the player doesn't know where the exit is so he has to guess his way out!

Amr follows simple algorithm to choose the path. Let's consider infinite command string "LRLRLRLRL..." (consisting of alternating characters 'L' and 'R'). Amr sequentially executes the characters of the string using following rules:

  * Character 'L' means "go to the left child of the current node"; 
  * Character 'R' means "go to the right child of the current node"; 
  * If the destination node is already visited, Amr skips current command, otherwise he moves to the destination node; 
  * If Amr skipped two consecutive commands, he goes back to the parent of the current node before executing next command; 
  * If he reached a leaf node that is not the exit, he returns to the parent of the current node; 
  * If he reaches an exit, the game is finished. 



Now Amr wonders, if he follows this algorithm, how many nodes he is going to visit before reaching the exit?

Input

Input consists of two integers h, n (1 ≤ h ≤ 50, 1 ≤ n ≤ 2h).

Output

Output a single integer representing the number of nodes (excluding the exit node) Amr is going to visit before reaching the exit by following this algorithm.

Examples

Input

1 2


Output

2

Input

2 3


Output

5

Input

3 6


Output

10

Input

10 1024


Output

2046

Note

A perfect binary tree of height h is a binary tree consisting of h + 1 levels. Level 0 consists of a single node called root, level h consists of 2h nodes called leaves. Each node that is not a leaf has exactly two children, left and right one. 

Following picture illustrates the sample test number 3. Nodes are labeled according to the order of visit.

<image>
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class TestClass {
	private static InputStream stream;
	private static byte[] buf = new byte[1024];
	private static int curChar;
	private static int numChars;
	private static SpaceCharFilter filter;
	private static PrintWriter pw;
	
	public static class Queue{
		private class node{
			int val;
			node next;
			node(int a){
				val = a;
				next = null;
			}
		}
		node head,tail;
		Queue(){
			head = null;
			tail = null;
		}
		public void EnQueue(int a){
			if(head==null){
				node p = new node(a);
				head = p;
				tail = p;
			}
			else{
				node p = new node(a);
				tail.next = p;
				tail = p;
			}
		}
		public int DeQueue(){
			int a = head.val;
			head = head.next;
			return a;
		}
		public boolean isEmpty(){
			return head==null;
		}
	}
	public static long pow(long x,long y,long m){
		if(y==0)
    		return 1;
    	long k = pow(x,y/2,m);
    	if(y%2==0)
    		return (k*k)%m;
    	else
    		return (((k*k)%m)*x)%m;
    }
	static long Inversex = 0,Inversey = 0;
	public static void InverseModulo(long a,long m){
		if(m==0){
			Inversex = 1;
			Inversey = 0;
		}
		else{
    		InverseModulo(m,a%m);
    		long temp = Inversex;
    		Inversex = Inversey;
    		Inversey = temp+ - (a/m)*Inversey;
    	}
    }
    static long mod1 = 1000000007;
    static long mod2 = 1000000009;
	public static long gcd(long a,long b){
		if(a%b==0)
			return b;
		return gcd(b,a%b);
	}
	public static boolean isPrime(long a){
		if(a==1)
			return false;
		else if(a==2||a==3)
			return true;
		for(long i=2;i<=Math.sqrt(a);i++)
			if(a%i==0)
				return false;
		return true;
	}
	public static double distance(int a,int b,int x,int y){
		return Math.sqrt(((long)(a-x)*(long)(a-x))+((long)(b-y)*(long)(b-y)));
	}
	public static class Pair implements Comparable<Pair> {
		long u;
		long v;
		BigInteger bi;
		public Pair(long u, long v) {
			this.u = u;
			this.v = v;
		}
		public int hashCode() {
			int hu = (int) (u ^ (u >>> 32));
			int hv = (int) (v ^ (v >>> 32));
			return 31 * hu + hv;
		}
		public boolean equals(Object o) {
			Pair other = (Pair) o;
			return u == other.u && v == other.v;
		}
		public int compareTo(Pair other) {
			return Long.compare(u, other.u) != 0 ? Long.compare(u, other.u) : Long.compare(v, other.v);
		}
		public String toString() {
			return "[u=" + u + ", v=" + v + "]";
		}
	}
	public static int seive(int a[],boolean b[],TreeSet<Integer> c){
		int count = 0;
		for(int i=2;i<a.length;i++){
			if(!b[i]){
				for(int j=i*i;j<a.length&&j>0;j=j+i)
					b[j] = true;
				c.add(i);
				a[count++] = i;
			}
		}
		return count;
	}
	public static void MatrixMultiplication(int a[][],int b[][],int c[][]){
		for(int i=0;i<a.length;i++){
			for(int j=0;j<b[0].length;j++){
				c[i][j] = 0;
				for(int k=0;k<b.length;k++)
					c[i][j]=(int)((c[i][j]+((a[i][k]*(long)b[k][j])%mod1))%mod1);
			}
		}
	}
	public static void Equal(int arr[][],int temp[][]){
		for(int i=0;i<arr.length;i++){
			for(int j=0;j<arr.length;j++)
				temp[i][j] = arr[i][j];
		}
	}
	public static class Trie {
		Node head;
		private class Node{
			Node a[] = new Node[2];
			boolean val;
			Node(){
				a[0] = null;
				a[1] = null;
				val = false;
			}
		}
		Trie(){
			head = new Node();
		}
		public void insert(Stack<Integer> s){
			Node temp = head;
			while(!s.isEmpty()){
				int q = s.pop();
				if(temp.a[q]==null)
					temp.a[q] = new Node();
				temp = temp.a[q];
			}
			temp.val = true;
		}
		public Node delete(Stack<Integer> s,Node temp){
			if(s.isEmpty())
				return null;
			int q = s.pop();
			temp.a[q] = delete(s,temp.a[q]);
			if(temp.a[q]==null&&temp.a[q^1]==null)
				return null;
			else
				return temp;
		}
		public void get(Stack<Integer> s,Stack<Integer> p){
			Node temp = head;
			while(!p.isEmpty()){
				int q = p.pop();
				if(temp.a[q]!=null){
					s.push(q);
					temp = temp.a[q];
				}
				else{
					s.push(q^1);
					temp = temp.a[q^1];
				}
			}
		}
	}
	private static void soln(){
		long h = nL();
		long n = nL();
		long y = (long)Math.pow(2, h);
		String a = "LR";
		int nm = 0;
		long x = 0;
		long count = 1;
		for(int i=0;i<h;i++){
			char ch = a.charAt(nm);
			nm=(nm+1)%2;
			long mid = (x+y)/2;
			if(ch=='L'){
				if(mid>=n){
					count+=1;
					y = mid;
				}
				else{
					count+=Math.pow(2, h-i);
					//i--;
					x=mid;
					nm=(nm+1)%2;
				}
			}
			else{
				if(n>mid){
					count+=1;
					x=mid;
				}
				else{
					count+=Math.pow(2, h-i);
					y=mid;
					nm=(nm+1)%2;
				}
			}
			//pw.println(count);
		}
		pw.println(count-1);
	}
	public static void main(String[] args) {
		InputReader(System.in);
		pw = new PrintWriter(System.out);
		soln();
		pw.close();
	}
	// To Get Input
	// Some Buffer Methods
	public static void InputReader(InputStream stream1) {
		stream = stream1;
	}
	private static boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
	private static boolean isEndOfLine(int c) {
		return c == '\n' || c == '\r' || c == -1;
	}
	private static int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}
	private static int nI() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	private static long nL() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	private static String nextToken() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}
	private static String nLi() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isEndOfLine(c));
		return res.toString();
	}
	private static int[] nIA(int n) {
		int[] arr = new int[n];
		for (int i = 0; i < n; i++)
			arr[i] = nI();
		return arr;
	}
	private static long[] nLA(int n) {
		long[] arr = new long[n];
		for (int i = 0; i < n; i++)
			arr[i] = nL();
		return arr;
	}
	private static void pArray(int[] arr) {
		for (int i = 0; i < arr.length; i++)
			pw.print(arr[i] + " ");
		pw.println();
		return;
	}
	private static void pArray(long[] arr) {
		for (int i = 0; i < arr.length; i++)
			pw.print(arr[i] + " ");
		pw.println();
		return;
	}
	private static boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}
	private interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}