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.BufferedReader;
import java.io.FileReader;
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
import java.io.*;
public class codeforces 
{ 
   static class Student{
       long x,y;
        Student(long x,long y){
            this.x=x;
            this.y=y;
        }
    }
    static int prime[];
    static void sieveOfEratosthenes(int n) 
    { 
        // Create a boolean array "prime[0..n]" and initialize 
        // all entries it as true. A value in prime[i] will 
        // finally be false if i is Not a prime, else true. 
        int pos=0;
        prime= new int[n+1]; 
        for(int p = 2; p*p <=n; p++) 
        { 
            // If prime[p] is not changed, then it is a prime 
            if(prime[p] == 0)
            { 
                // Update all multiples of p
                prime[p]=p;
                for(int i = p*p; i <= n; i += p) 
                    prime[i] = p; 
            } 
        } 
    }
static    class Sortbyroll implements Comparator<Student> 
{ 
    // Used for sorting in ascending order of 
    // roll number 
    public int compare(Student c, Student b) 
    { 
        if(c.x<=b.x)
            return -1;
        return 1;
    } 
} 
static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
 
    static class Edge{
        int a,b;
        Edge(int a,int b){
            this.a=a;
            this.b=b;
        }
    }
    static class Trie{
        Trie z,o;
        int c;
        Trie(){
            z=null;
            o=null;
            c=0;
        }
    }
    static long ans;
    static int parent[];
    static int rank[];
    static int b[][];
    static int seg[];
   // static int ans;
    static Trie root;
    static void solve()throws IOException{
        FastReader sc=new FastReader();
        long h,n;
        h=sc.nextLong();
        n=sc.nextLong();
        ans=0;
        tr(1,1,(long)Math.pow(2,h),n,0,h);
        System.out.println(ans);
    }
    static void tr(int d,long s,long e,long n,long h,long o){
        if(s==e){
            return;
        }
        long mid=(s+e-(long)1)/(long)2;
        if(n>mid){
            if(d==1){
                ans+=(long)Math.pow(2,o-h);
                tr(1,mid+1,e,n,h+1,o);
            }
            else{
                ans+=1;
                tr(1,mid+1,e,n,h+1,o);
            }
        }
        else{
            if(d==1){
                ans+=1;
                tr(0,s,mid,n,h+1,o);
            }
            else{
                ans+=(long)Math.pow(2,o-h);
                tr(0,s,mid,n,h+1,o);
            }
        }
    }
    static void update(int l,int r,int s,int e,int in,int val,int le){
        if(s>e||s>r||e<l)
            return;
        if(s==e){
            seg[in]=val;
            return;
        }
        update(l,r,s,(s+e)/2,2*in+1,val,le-1);
        update(l,r,(s+e)/2+1,e,2*in+2,val,le-1);
        if(le%2!=0)
            seg[in]=seg[2*in+1]|seg[2*in+2];
        else
            seg[in]=seg[2*in+1]^seg[2*in+2];
    }
    public static void main(String[] args){
        //long sum=0;
        try {
                codeforces.solve();
                } catch (Exception e) {
                    e.printStackTrace();
                }
    }
 /*static long power(long x, long y, long p) 
{ 
    long res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    /*while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if ((y & (long)1)%2!=0) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } */
    //return res%p; 
   static int find(int x) 
    { 
        // Finds the representative of the set 
        // that x is an element of 
        while(parent[x]!=x) 
        { 
            // if x is not the parent of itself 
            // Then x is not the representative of 
            // his set,
            x=parent[x];
  
            // so we recursively call Find on its parent 
            // and move i's node directly under the 
            // representative of this set 
        } 
  
        return x; 
    }
    static void union(int x, int y) 
    { 
        // Find representatives of two sets 
        int xRoot = find(x), yRoot = find(y); 
  
        // Elements are in the same set, no need 
        // to unite anything. 
        if (xRoot == yRoot) 
            return; 
  
         // If x's rank is less than y's rank 
        if (rank[xRoot] < rank[yRoot]) 
  
            // Then move x under y  so that depth 
            // of tree remains less 
            parent[xRoot] = yRoot; 
  
        // Else if y's rank is less than x's rank 
        else if (rank[yRoot] < rank[xRoot]) 
  
            // Then move y under x so that depth of 
            // tree remains less 
            parent[yRoot] = xRoot; 
  
        else // if ranks are the same 
        { 
            // Then move y under x (doesn't matter 
            // which one goes where) 
            parent[yRoot] = xRoot; 
  
            // And increment the the result tree's 
            // rank by 1 
            rank[xRoot] = rank[xRoot] + 1; 
        } 
    } 
    static long gcd(long a, long b) 
    { 
        if (a == 0) 
            return b; 
        return gcd(b % a, a); 
    }
}