#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    if(n>=31)cout<<m<<endl;
    else{
        cout<<m%(1<<n)<<endl;
    }
    return(0);
}

#include <iostream>
#include <cmath>
using namespace std;
int m, n;
int main()
{
	cin >> n >> m;
	int kkk = pow(2, n);
	cout << m % kkk;
	return 0;
}

#include <iostream>
#include <cmath>
using namespace std;
int main(){
	long long n,m,k;
	cin>>n>>k;
	m=pow(2,n);
	cout<<k%m<<endl;
	return 0;
}

#include <iostream>
#include<cmath>
using namespace std;

int main() {
	// your code goes here
	long long int n,m,power;
	cin >> n>> m;
	power = pow(2.0,n);
	cout <<m%power;
	return 0;
}

#include<iostream>
#include<cstdio>
using namespace std;
int main() {
	int n,m,i;
	cin>>n>>m;
	int x=1;
	for (i=1;i<=n;i++) {
		x=x*2;
		if (x>m) break;
	}
	cout<<m % x<<endl;
}

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int m,n;
	cin>>n>>m;
	int x=pow(2,n);
	cout<<m%x;
	return 0;
}

#include <iostream>
#include <cmath>

using namespace std;

int main() {
  int n, m, result;

  cin >> n;
  cin >> m;

  result = pow(2, n);

  cout << (m % result) << endl;

  return 0;
}

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<stdio.h>
#define t(a) scanf("%d",&a);
#define tt(a) printf("%d",a);
using namespace std;
int n,m;
int main(){
	t(n); t(m);
	int x=pow(2,n);
	tt(m%x);
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,res;
    scanf("%d %d",&n,&m);
    res=pow(2,n);
    res=m%res;
    printf("%d",res);

}

#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, m;
	cin >> n >> m;
	if (n >= 27) { // log<2>(10^8)= 26.575424759
		return cout << m, 0;
	}
	cout << (m % (1 << n));
}

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n; cin >> n;
    int m; cin >> m;
    long long data = pow(2,n);
    if (data == m) {
        cout << 0;
    }
    else if (sqrt(m) < n) {
        cout << m;
    } else if (m < data) {
        cout << m;
    } else {
        int ans = m % data;
        cout << ans;
    }
    return 0;
}

#include<iostream>
#include<math.h>
#include<string.h>
using namespace std;

int main()
{
    long long int n,m,v=2,i,b=1;
    cin>>n>>m;
    if(n>=m)
    {
        cout<<m;
        return 0;
    }
    if(n>50)
    {
        if(n>m/100000000)
        {
            cout<<m;
        return 0;
        }
    }
    for(i=2;i<11;i++)
    {
        if(n%i==0)
        {
            v=pow(v,i);
            n=n/i;
        }
        else
            break;
    }
    for(i=1;i<=n;i++)
    {
        b=b*v;
    }
    cout<<(m%b);
    return 0;
}

#include<iostream>
#include<cmath>
using namespace std;
int n,m;
int main()
{
	cin>>n>>m;
	cout<<(n>=30?m:m%(int)pow(2,n))<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;
#define rep(i,a,n) for(int i=a; i<n; i++)
#define endl "\n"
#define E "\n"
#define show(arr) REP(i,arr.size()){cout<<arr[i]<<" ";}
const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;
const int MAX = 1e18;
int n,m;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void solve()
{
    cin>>n>>m;
    if (n>=27) cout<<m<<E;
    else cout<<(m%binpow(2,n))<<E;
    //scout<<binpow(2,n)<<E;
}

signed main()
{
    int t=1;
    //cin>>t;
    WL(t)solve();

    return 0;
}

#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <queue>
#include <limits>
#include <deque>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define MN 0LL
#define Mx 2000000005
#define Mn -Mx
#define MX 20000000000000005
using namespace std;
int readint(){
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9'){
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}
inline string tos(int x){
	string s;
	while(x) s=(char)(x%10+'0')+s,x/=10;
	return s;
}
inline int pt(int a[],int l,int r){
	int p,i,j;
	p=a[l];
	i=l;
	j=r+1;
	for(;;){
		while(a[++i]<p) if(i>=r) break;
		while(a[--j]>p) if(j<=l) break;
		if(i>=j) break;
		else swap(a[i],a[j]);
	}
	if(j==l) return j;
	swap(a[l],a[j]);
	return j;
}
inline void q_sort(int a[],int l,int r){
	int q;
	if(r>l){
		q=pt(a,l,r);
		q_sort(a,l,q-1);
		q_sort(a,q+1,r);
	}
}
int main(){
	long long x,y,i,j;
	unsigned long long t,v,cnt=0;
	cin>>x>>y;
	t=1;
	v=y;
	for(i=0;i<x;i++){
		t*=2;
		if(t>y){
			cout<<y<<endl;
			return 0;
		}
	}
	cout<<y%t<<endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{

int n,m;
long long int z=1;
cin >> n >> m ;
if(m<=n || n>32  )  cout  << m;
else if (n==1)  cout << m%2;
else
{for(int i=1;i<=n ;i++){
    z=z*2;
}

cout << m%z;
}

}

//What is love?

#include <iostream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <ctype.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define FOR(i,n,m) for(int i=n; i<m; i++)
#define ROF(i,n,m) for(int i=n; i>m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define ri(a) scanf("%d",&a)
#define rii(a,b) scanf("%d %d",&a,&b)
#define riii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define lri(a) scanf("%lld",&a)
#define lrii(a,b) scanf("%lld %lld",&a,&b)
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define debug true
#define dprintf debug && printf

const int INF = 0x3f3f3f3f;
const ll INFLL = 1e18;
const int MOD = 1e9+7;
const int MAXN = 2e5+5;

//Baby don't hurt me

ll n,m;

//Don't hurt me

int main(){
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);

	lrii(n,m);

	if(n>=64){
		printf("%lld\n", m);
	}else{
		ll mod = 1LL;
		FOR(i,0,n) mod*=2;
		printf("%lld\n", m%mod);
	}

    return 0;
}
//No more

//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<stack>
#include<vector>
//#include<conio.h>
#include<string>
#include<map>
#include<cstdlib>
#include<queue>
#include<math.h>
#include<time.h>
#include<cstdio>
#include<stdio.h>
#include<algorithm>
using namespace std;
inline int read(){
	int ans=0,flag=1;
	char ch=getchar();
	while((ch>'9'||ch<'0')&&ch!='-') ch=getchar();
	if(ch=='-') flag=-1,ch=getchar();
	while(ch>='0'&&ch<='9'){
		ans=(ans<<1)+(ans<<3)+(ch^'0');
		ch=getchar();
	}
	return ans*flag;
}
int n,m;
int main(){
	n=read(),m=read();
	printf("%d\n",n>=30?m:(m%(1<<n)));
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main() {

	long long n, m, ans = 1;
	cin >> n;
	cin >> m;

	for(long long i = 0; i < n && ans <= m; i++) {
		ans *= 2;
	}

	cout << m % ans << endl;

	return 0;
}

//#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;

#define ec " \n"
#define pb push_back
#define ll long long
#define mod 1999999999

ll n, m, a;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	ll res = 1;
	a = 2;
	while (n) {
		if (n & 1) {
			res *= a;
			res %= mod;
			n--;
		}
		a *= a;
		a %= mod;
		n /= 2;
	}
	cout << m % res;
}

#include "bits/stdc++.h"
#define fi first
#define se second
#define int long long
using namespace std;

int m,n;

signed main()
{
    cin>>n>>m;
    int cur=1,step=0;
    if (n==0)
    {
        cout<<0;
        return 0;
    }
    while (cur<=m && step<n)
    {
        cur*=2;
        step++;
    }
    if (step==n)
    {
        cout<<m%cur;
    }
    else
    {
        cout<<m;
    }
}

#include<bits/stdc++.h>
using namespace std;

#define FAST ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define f(i,s,e) for(int i=s;i<e;++i)
#define rf(i,s,e) for(int i=s;i>=e;--i)
#define ms(x,a) memset(x,a,sizeof(x))
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define endl "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define all(v) v.begin(),v.end()
#define pb push_back
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound

///// data types /////
#define ll long long
#define vi vector<int>
#define viit vector<int>::iterator
#define vc vector<char>
#define vcit vector<char>::iterator

template <typename T> inline T sqr(T x) { return x * x; }
template <typename T> inline T abs(T x) { return x < 0? -x : x; }
template <typename T> inline T gcd(T a, T b) { return b? gcd(b, a % b) : a; }
template <typename T> inline bool chmin(T &x, const T& y) { if (x > y) { x = y; return 1; } return 0; }
template <typename T> inline bool chmax(T &x, const T& y) { if (x < y) { x = y; return 1; } return 0; }

#define PI 3.141592653589793
#define MOD 1000000007

inline void read(int& n)
{
    n=0;
	bool neg = 0;
	register int c = getchar();
	while((c<48 || c>57) && c != '-') c = getchar();
	if(c == '-') neg = 1, c = getchar();
	while(c>47 && c<58) n= (n<<3)+(n<<1)+(c^48), c = getchar();

	if(neg) n=-n;
}

int main()
{
    FAST
    ll n,m; cin>>n>>m;
    cout<<( n<63 ? m%(1ll<<n) : m%((1ull<<63)-1));

}

#include <iostream>

using namespace std;

int32_t main()
{
	int n, m;
	cin >> n >> m;
	int cnt = 1, ans = 2;
	while (cnt < n && m >= ans)
	{
		ans *= 2;
		cnt++;
	}
	cerr << ans << endl;
	if (m >= ans)
		m %= ans;
	cout << m << endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define mod 100000000
long long power(long long x)
{
  long long ans=2;
  long long c=1;

  while(x>1)
  {
    if(x%2==0)
    {
      x=x/2;
      ans=(ans*ans);
    }else
    {
      x--;
      c=(c*ans);
    }

  }
  return (ans*c);
}

int main()
{
  long long n,m;
  cin>>n>>m;
  if(n<=27)
   cout<<m%power(n);
else
cout<<m;
}

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>

using namespace std;
const int N=5e5+10;
int a;
 long long n,k;
long long ppow(long long a,long long b)
{
    long long ans=1;
    while(b--)
    {
        ans*=a;
        if(ans>k)
            return -1;
    }
    return ans;
}
int main()
{

    ios::sync_with_stdio(false);
    while(cin>>n>>k)
   {
       long long x=1;
       long long ans=ppow(2,n);
       if(ans==-1)
       cout<<k<<endl;
       else
        cout<<k%ans<<endl;

    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,m,ans;
int main(){
    cin>>n>>m;
    if(n>=30)cout<<m<<endl;
        else cout<<m%(1<<n)<<endl;
    return 0;
}

//g++  5.4.0
#include <cmath>
#include <iostream>

int main()
{
    int m;
    int n;
    std::cin>>n>>m;
    std::cout<<m%static_cast<int>(pow(2,n));
}

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;

int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        double d=log(m)/log(2);
        if(d<n)
            {
                printf("%d\n",m);
            }
        else
        {
            long long mod=pow(2,n);
            printf("%d\n",m%mod);
        }
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,m;
int main(){
    cin>>n>>m;
    if (n>=30) cout<<m;
    else cout<<(m%(1<<n));
    return 0;
}

#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
#define N 123456
#define MAXVAL 2000000000
int n, m;
int a[31];
void solve() {
	if (n < 30) {
		printf("%d\n", m % (1 << n));
	}
	else {
		printf("%d\n", m);
	}
}
int main() {
	while (scanf("%d %d", &n, &m) != EOF) {
		solve();
	}
	return 0;
}

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
 {
  ll n, m;
  cin>>n>>m;
  if(n>=27)cout<<m;
  else {
    ll a=pow(2,n);
    cout<<m%a;
  }
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
//      std macros
typedef long long ll;
typedef pair<int ,int> pii;
typedef pair<ll ,ll> pll;
//      dereference
#define F first
#define S second
#define pb push_back
#define mp make_pair
//      loops
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,a,b) for(int i=a;i<=b;++i)
#define PER(i,b,a) for(int i=b;i>=a;--i)
#define all(X) (X).begin(), (X).end()
//      I/O
#define sd(n) scanf("%d",&n)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define sll(n) scanf("%lld",&n)
#define sll2(x,y) scanf("%lld%lld",&x,&y)
#define sll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define ss(s) scanf("%s",s)
//      debug
#define debug(x) cerr<<"debug->"<<#x<<"::"<<x<<endl
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n"
#define debug4(x,y,z,w) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<"\n"
//      set values
#define mset(n,k) memset(n,k,sizeof(n))
//modular expo
ll power(ll a,ll b, ll c){
    ll x=1,y=a;
    while(b>0){
        if(b&1)
            x=(x*y)%c;
        y=(y*y)%c;
        b/=2;
    }
    return x%c;
}
int dx[]={0,-1,0,1};
int dy[]={-1,0,1,0};//clockwise from left
int dr[]={1,1,0,-1,-1,-1, 0, 1};
int dc[]={0,1,1, 1, 0,-1,-1,-1};//anticlockwise from down
int main() {

	ll n,m;
	sll2(n,m);
	ll po = 1;
	while(n--) {
		po*=2LL;
		if(po>m)
			break;
	}
	ll ans = m%po;
	printf("%lld\n",ans);

	return 0;
}

#include<iostream>
#include<string>
using namespace std;
int n,m;
int main()
{
	cin>>n>>m;
	if(n>=30) cout<<m;
	else cout<<m%(1<<n);
	return 0;
}

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
unsigned long int n,m,p=2,q;
cin>>n>>m;
for(int i=1;i<n;i++)
{
 p=2*p;
 if(p>m)
 {
 	break;
 }

}
if(p>m)
cout<<m;
else
cout<<m%p;

return 0;
}

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <stack>
#include <set>
#include <cassert>
#include <ctime>
#include <unordered_set>
#include <complex>
#include <queue>

#define vd vector<double>
#define all(v) v.begin(), v.end()

#define mp make_pair
#define pb push_back
#define forn(i, l) for (int i = 0; i < l; i++)

using namespace std;
typedef pair<int, int> pi;
typedef complex<double> cd;
typedef long double ld;
typedef vector<int> vi;
typedef pair<ld, ld> pd;
typedef long long li;
const int N = 4096;
const ld eps = 0.2, eps2 = 0.0001;
const int INF = (int)1e9 + 7, MOD = INF;
const long long LINF = 1e16;
const double PI = acos(-1.0);

int n, m;

int main() {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	cin >> n >> m;
	if (n > 28) {
		cout << m;
	} else {
		li s = 1;
		forn(i, n) {
			s *= 2;
		}
		cout << m % s;
	}
 }

#include <iostream>
#include <cmath>
using namespace std;

int rez(long long a,long long n)
{
    if(!n) return 1;
    long long f = rez(a, n/2);
    if (n % 2 == 0){
        return f*f;
    }
    else return a*f*f;
}

int main() {
    long long n,m,s, a= 2;
    cin>>n>>m;
    int k = 0;

   while (rez(a, k)<= m)
    {
        k++;
    }

    if (n >= k)
        cout<< m;

    else
    cout<<m % rez(a,n);

return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
    long long n,m,x;
    cin>>n>>m;
    x=pow(2,n);
cout<<m%x;
    return 0;
}

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<cmath>
#define maxn 100005
#define inf 0x7fffffff
using namespace std;
int n, m;
int base[35];
void init()
{
	base[1] = 2;
	for (int i = 2; i <= 30; i++)
	{
		base[i] = base[i - 1] * 2;
		//cout << base[i] << endl;
	}
	//cout << base[30] << endl;
}
int main()
{
	init();
	while (~scanf("%d%d", &n, &m))
	{
		if (n > 30) cout << m << endl;
		else cout << m%base[n] << endl;
	}
	return 0;
}

#include<iostream>
using namespace std;
int main() {

	int n, m,x=1;
	cin >> n >> m;
	if (n >= 27)cout << m;
	else if (n < 27) {//직접계산
		for (int i = 0; i < n; i++) {
			x *= 2;
		}cout << m%x;
	}
	return 0;
}

/*

m<2^n 이면 m%2^n=m

	m vs 2^n 의 대소비교 -> lg(m) vs n 의 대소비교

	1 ≤ m ≤ 10^8 에서 밑이 2인 로그를 취함
	0 ≤ lg(m) ≤ 8lg10  *** 8lg10 = 8/log2 = 8/0.301 = 약 26.xxx
	따라서 0 ≤ lg(m) ≤ 26.xxx
*/

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    long long int p,m;
    cin>>p>>m;
    if(p>=60){
        cout<<m;
        return 0;
    }
    long long s;
    s=pow(2,p);

    cout<<m%s;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    if(n>=27){
        cout<<m;
    }
    else{
        cout<<m%(1<<n);
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,m,x;
int main()
{
	cin>>n>>m;
	if(n>=30)
	cout<<m<<endl;
	else
	cout<<(m%(1<<n))<<endl;
	return 0;
}

#include<stdio.h>
int main()
{
    long n,m,sum=1;
    int i,flag=1;
    scanf("%ld %ld",&n,&m);
    for(i=1;i<=n;i++){
        sum=sum*2;
        if(sum>m){
            flag=0;
            printf("%d",m);
            break;
        }
    }
    if(flag)
        printf("%ld",m%sum);
    return 0;
}

// ConsoleApplication2.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"
#include <iostream>

size_t Pow(size_t d) {
  size_t res = 1;
  for (size_t i = 1; i < d + 1; ++i) {
    res *= 2;
  }

  return res;
}

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);

  size_t n, m;
  std::cin >> n >> m;
  if (n > 26) {
    std::cout << m;
  } else {
    size_t p = Pow(n);
    std::cout << (m % p);
  }

  return 0;
}

#include<bits/stdc++.h>
# include <stdio.h>
# include <stdlib.h>
#include <iostream>
#include<set>
#include<sstream>
using namespace std;
//int t[4][2]={{0,-1},{-1,0},{1,0},{0,1}};//字典序最小
//char a[7][10]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
long long gcd(long long n,long long m){
	return m==0?n:gcd(m,n%m);
}
long long lcm(long long a, long long b) {
  return a / gcd(a, b) * b;
}
#define oo 0x3f3f3f3f
#define pi 3.14159265358979
//#define mod 1000000007
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
/*struct node{
	int x,y,ts;
}s,ns;*/
//int a[33],b[33];
struct node{
int x,y;

bool operator<(const node a) const{
	if(a.x<x){
		return 0;
	}
	return a.y>y;
}
};
int run(int y){
	if(y%400==0){
		return 1;
	}
	if(y%100!=0&&y%4==0){
		return 1;
	}
	return 0;
}
long long  q(long long  x,long long  n,long long mod){//快速幂
    long long  ans=1;
	while(n){
		if(n&1){
			ans=x*ans%mod;
		}
		n=n>>1;
		x=x*x%mod;
	}
	return ans%mod;
}
long long  qcpow(long long  a,long long  b){//快速乘
     long long  ans=0;
	while(b){
		if(b&1){

			ans=(a+ans);
		}
		b=b>>1;
		a=(a+a);
	}
	return ans;
}
long long  qpow(long long  x,long long  n){//快速幂
    long long  ans=1;
	while(n){
		if(n&1){
			ans=qcpow(x,ans);
		}
		n=n>>1;
		x=x*x;
	}
	return ans;
}

long long lj(long long n){
	long long sum=0 ;
	for(int i=0;i<=n;i++){
		sum+=i;
	}
	return sum;
}
long long jc(long long n,long long cnt){
	long long sum=1;
	while(cnt--){
		sum*=n;
		n-=1;
	}
	if(sum==1){
		return 0;
	}
	return sum;
}
int fa[1000*1100];
int find(int u){
	int tu=u;
	while(fa[tu]!=tu){
		tu=fa[tu];
	}
	return tu;
}
string s2S(int s){
	stringstream ss;
	string str;
	if(s<10){
	ss<<'0';
	}
	ss<<s;
	ss>>str;
	return str;
}
void s2i(string &s,int &num){
	stringstream ss;
	ss<<s;
	ss>>num;
}
void wys(int x){//位运算此次出现32位的2进制
	for(int i=0;i<32;i++){
		printf("%d",(x>>(31-i))&1);
	}
}
int combin(int x, int y){
	int tx=find(x);
	int ty=find(y);
	if(tx==ty){
		return 0;
	}
	else {
		fa[tx]=ty;
		return 1;
	}
}
int flag[100010];
int prime[100010];
int t;
void pri(){
	flag[0]=1;
	flag[1]=1;
	for(int i=2;i<80000;i++){
		if(!flag[i]){
			prime[++t]=i;
		//	cout<<prime[t]<<endl;
		}
		for(int j=1;j<=t&&i*prime[j]<=80000;j++){
		flag[i*prime[j]]=1;
		if(i%prime[j]==0){
			break;
		}
		}
	}
}

//int dir[4]={1,-1,2,-2};
//int dir[6]={1,2,3,-1,-2,-3};
int dir[4][2]={0,1,1,0,0,-1,-1,0};
//int dir[8][2]={0,1,1,0,0,-1,-1,0,1,1,1,-1,-1,1,-1,-1};

//long long ans=0;

int dp1(){
		int n,k;
	int d[100][100];
	cin>>n>>k;
	int v[n+10],w[n+10];
	for(int i=1;i<=n;i++){
		cin>>w[i];
		cin>>v[i];
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<n;j++){
			d[i][j]=0;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=k;j++){
			if(j<w[i]){
				d[i][j]=d[i-1][j];
			}
			else {
				if(d[i-1][j]>d[i-1][j-w[i]]+v[i]){
					d[i][j]=d[i-1][j];
				}
				else {
					d[i][j]=d[i-1][j-w[i]]+v[i];
				}
			}
		}

	}
	return d[n][k];
}
int day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int solve(const string &str){
	if(str.rfind('A')-str.find('A')==2&&str.rfind('2')-str.find('2')==3&&str.rfind('3')-str.find('3')==4&&str.rfind('4')-str.find('4')==5){
	return 1;
	}
	return 0;
}
int prim[168]={2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997};
struct M{//矩阵快速幂
	long long data[2][2];
	M(){
		memset(data,0,sizeof(data));
	}
};
M mul(M a,M b){
	M ans;
	ans.data[0][0]=(a.data[0][0]*b.data[0][0]+a.data[0][1]*b.data[1][0])%1000000007;
	ans.data[0][1]=(a.data[0][0]*b.data[0][1]+a.data[0][1]*b.data[1][1])%1000000007;
	ans.data[1][0]=(a.data[1][0]*b.data[0][0]+a.data[1][1]*b.data[1][0])%1000000007;
	ans.data[1][1]=(a.data[1][0]*b.data[0][1]+a.data[1][1]*b.data[1][1])%1000000007;
	return ans;
}
M qqpow(M m,long long n){
	M E;
	E.data[0][0]=1;
	E.data[1][1]=1;
	while(n!=0){
		if(n&1){
			E=mul(E,m);
		}
		m=mul(m,m);
		n=n>>1;
	}
	return E;
}
string rev(string s){
	string ans;
	for(int i=s.size()-1;i>=0;i--){
		ans+=s[i];
	}
	return ans;
}
int lca(string s1,string s2){
	int len=s1.size();
	int dp[len+5][len+5];
	for(int i=0;i<len;i++){
		if(s1[0]==s2[i]){
			dp[0][i]=1;
		}
		else {
			if(i==0){
				dp[0][i]=0;
			}
			else {
				dp[0][i]=dp[0][i-1];
			}
		}

	}
	for(int i=0;i<len;i++){
		if(s1[i]==s2[0]){
			dp[i][0]=1;
		}
		else {
			if(i==0){
				dp[i][0]=0;
			}
			else {
				dp[i][0]=dp[i-1][0];
			}
		}

	}
	for(int i=1;i<len;i++){
		for(int j=1;j<len;j++){
			if(s1[i]==s2[j]){
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else {
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	for(int i=0;i<len;i++){
		for(int j=0;j<len;j++){
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}
	return dp[len-1][len-1];
}
int dist[10000];
int S[10000];
int path[10000];
int edge[1000][1000];
void dij(int u){
	/*for(int i=1;i<=n;i++){
		S[i]=0;
		dist[i]=edge[u][i];

	}
	S[u]=1;
	for(int i=1;i<=n;i++){
		int minn=oo;
		int v=u;
		for(int j=1;j<=n;j++){
			if(!S[j]&&minn>dist[j]){
				minn=dist[j];
				v=j;

			}
		}
		//cout<<dist[v]<<" "<<v<<endl;
		S[v]=1;
		for(int j=1;j<=n;j++){
			if(!S[j]&&dist[v]+edge[v][j]<dist[j]){
				dist[j]=dist[v]+edge[v][j];
				//cout<<dist[j]<<"--"<<j<<endl;
			}
		}
	}*/
}
long long mapp[2000][2000];
long long dp[50][50][13][13];
int n,m,k;
int dfs_dp(int x,int y,int cnt,int maxn){
	if(dp[x][y][cnt][maxn+1]!=-1){
		return dp[x][y][cnt][maxn+1];
	}
	if(x==n&&y==m){
		if(cnt==k||(cnt==k-1&&maxn<mapp[x][y])){
			dp[x][y][cnt][maxn+1]=1;
			return dp[x][y][cnt][maxn+1];
		}
		else {
			dp[x][y][cnt][maxn+1]=0;
			return dp[x][y][cnt][maxn+1];
		}
	}
	long long ans=0;
	if(x+1<=n){
		if(maxn<mapp[x][y]){
			ans+=dfs_dp(x+1,y,cnt+1,mapp[x][y]);
		}
		ans+=dfs_dp(x+1,y,cnt,maxn);
	}
	if(y+1<=m){
		if(maxn<mapp[x][y]){
			ans+=dfs_dp(x,y+1,cnt+1,mapp[x][y]);
		}
		ans+=dfs_dp(x,y+1,cnt,maxn);
	}
	dp[x][y][cnt][maxn+1]=ans%1000000007;
	return dp[x][y][cnt][maxn+1];
}
const int mm=1e5+10;
vector<long long> p[mm];
long long w[mm];
long long ww[mm];
long long ans=0;
void dfs_s(int root,int cnt,int f){//遍历每颗树 root当前的根，f是root父节点

	if(root==n-1&&cnt==k)
	{
		ans++;
		cout<<f<<endl;
		return ;
	}
	if(cnt>=k){
		return ;
	}
	for(int i=0;i<p[root].size();i++){
		int son=p[root][i];
		dfs_s(son,cnt+1,root);
	}
}

int h[100000],W[100000];
int book[1000000];
int a[40][40];
int dpp[100005];
int solve(int mid){

}

int main(int argc, char** argv){
	long long n,m;
	cin>>n;
	cin>>m;
	printf("%d\n", n >= 31 ? m : m % (1 << n));

	return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
ll n, m;
ll binpow(ll a, ll b) {
         ll res = 1;
         while (b) {
                  if (b & 1) {
                           res *= a;
                  }
                  a *= a;
                  b >>= 1;
         }
         return res;
}
int main() {
         scanf ("%lld %lld", &n, &m);
		 if (n >= 30) {
		 	printf("%lld", m);
		 }
		 else {
		 	printf("%lld", m % (1 << n));
		 }
		 return 0;
}

/**************************************************
filename       :A.cpp
author         :maksyuki
created time   :2018/1/8 22:22:09
last modified  :2018/1/8 23:09:32
file location  :C:\Users\abcd\Desktop\codeforces
***************************************************/

#pragma comment(linker, "/STACK:102400000,102400000")
#include <set>
#include <bitset>
#include <list>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <vector>
#include <ios>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <complex>
#include <numeric>
#include <functional>
#include <cmath>
#include <ctime>
#include <climits>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cassert>
using namespace std;

#define CFF freopen ("in", "r", stdin)
#define CFO freopen ("out", "w", stdout)
#define CPPFF ifstream cin ("in")
#define CPPFO ofstream cout ("out")
#define	DB(ccc)	cout << #ccc << " = " << ccc << endl
#define	DBT printf("time used: %.2lfs\n", (double) clock() / CLOCKS_PER_SEC)
#define PB push_back
#define MP(A, B) make_pair(A, B)

typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;
typedef pair <int, int> PII;
typedef pair <int, bool> PIB;

const int INF = 0x7F7F7F7F;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const double PI = 2 * acos (0.0);
const int maxn = 1e5 + 6666;

int main()
{
#ifdef LOCAL
    CFF;
    //CFO;
#endif
    int n, m;
    while(cin >> n >> m) {
        int ans = 0, tmp = 1;
        for(int i = 0; i < n; i++) {
            ans += (m % 2) * tmp;
            tmp <<= 1;
            m /= 2;
        }
        cout << ans << endl;
    }

    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    long n,m,x;
    scanf("%ld %ld",&n,&m);
    if(pow(2,n)>m)
        printf("%ld",m);

    else{
            x=pow(2,n);
            printf("%ld\n",m%x);
        }
        return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=2e9;
ll a,m;
inline ll exp(ll x, ll n)  {
    if(n==0) return 1;
    if(n==1) return x;
    if(n%2==0) return exp((x*x)%mod,n/2);
    if(n%2==1) return (x*exp((x*x)%mod,n/2))%mod;}
inline int in() { int x; scanf("%d", &x); return x; }
int main (){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 cin>>a>>m;
 if(a>=32){cout<<m;return 0;}
 cout<<m%exp(2,a);
	return 0;}

 #include<bits/stdc++.h>
using namespace std;
typedef vector <int> vi;
typedef map<int,int> mii;
typedef pair<int,int> pii;
#define ll long long int
#define pb push_back
#define PI 3.1415926535897932384626
#define boost ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MOD 4294967296
#define MAX 100001
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define F first
#define S second
#define mset(x,v) memset(x, v, sizeof(x))
#define left(x) 2*x
#define right(x) (2*x) + 1
#define ALL(t) (t).begin(),(t).end()
#define pi 3.14159265358979323846264338327950
#define ret return 0
#define rev(s) reverse(s.begin(),s.end())
ll modp(ll a, ll b)
{
        ll ans=1;
        while(b != 0)
        {
                if(b%2 == 1)
                ans=(ans*a);

                a=(a*a);
                b /= 2;
        }
        return ans;
}
int main()
{
      boost;
      ll n,m;
      cin>>n>>m;
      if(n>m)
      cout<<m<<endl;
      else
      {
            int x=ceil(log(m)/log(2));
            if(n>x)
            cout<<m<<endl;
            else
            cout<<m%modp(2,n)<<endl;
      }
}

#include <iostream>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

#define pii pair<int, int>
#define pll pair<long long, long long>
#define vi vector<int>
#define vii vector<pair<int, int>>
#define pb push_back
#define mp make_pair
#define fill(m, z) memset(m, z, sizeof(m))
#define forn(i, b, e) for (i = b; i < e; ++i)
#define forne(i, b, e) for (i = b; i != e; ++i)
#define forb(i, e, b) for (i = e; i >= b; --i)
#define mod (long long)(1e9+9)

int main() {
    int n, m, s = 2;
    cin >> n >> m;
    while (n > 1 && s <= m) {
        s <<= 1;
        --n;
    }
    cout << m % s << endl;
    return 0;
}

#include<bits/stdc++.h>
#define pb push_back()
#define pf              printf
#define sf            	scanf
#define sn(a)          	scanf("%lld",&a)
#define snn(a,b)       	scanf("%lld %lld",&a,&b)
#define snnn(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)
#define ll long long
#define M 10000007
using namespace std;

int main()
{

		ll n,m;
		cin>>n>>m;
		if(n>27)cout<<m<<endl;
		else{
		ll p=pow(2,n);
		 cout<<m % p<<endl;}

	return 0;
}

#include <stdio.h>
#include <math.h>

int main()
{
	int n, m;
	scanf_s("%d", &n);
	scanf_s("%d", &m);
	printf("%d", m % int(powf(2,n)));
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main() {
    int m, n;
    cin >> n >> m;
    int x = pow(2,n);
    int ans = m % x;
    if( n >= 31) ans = m;
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>
#define ll long long int
#define db double
#define fl float
#define ii int
#define endln "\n"
#define goodluck_code() main()
#define _Open_Minded_Short_Code_ return 0;
using namespace std;
ll _gcd(ll a,ll b){
	if(b == 0) return a;
	else
	return _gcd(b , a%b);
}
ll _nt(ll n){
	if(n<2) return 0;
	else
	for(int i=2;i*i<=n;i++)
	if(n%i==0) return 0;
	return 1;
}
ll _pm(ll a, ll n, ll m) {
    if(n == 0) return 1%m;
    if(n == 1) return a%m;
    ll t = _pm(a,n/2,m) % m;
    t = (t * t) % m;
    if(n % 2)
    	t = (t * a) % m;
    return t%m;
}
int a[1000007];
vector <ll> ve,ve1,ve2,ve3;
stack <ll> st,st1,st2,st3;
set <ll> se,se1,se2,se3;
map<ll,ll> mp,mp1,mp2,mp3;
ll a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0;
ll b1 = 1, b2 = 1, b3 = 1, b4 = 1, b5 = 1;
ll dem = 0, dem1 = 0, dem2 = 0,dem3 = 0, dem4 = 0;
ll temp = 0, temp1 = 0 , tamp = 0 , tamp1 = 0;
string s1, s2, s3, s4, s5, s6;
ll n,m,x,y,z;
ii goodluck_code(){
	cin>>n>>m;
	a1 = _pm(2,n,100000000000000000);
	if(a1 > m || n >= m || a1 == 0){
		cout<<m<<endln;
	}else{
		cout<<m % a1<<endln;
	}

	_Open_Minded_Short_Code_
}

#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m;
cin>>n>>m;
int r = pow(2,n);
if(n>m){
    cout<<m<<endl;
}
else{
    cout<<m%r<<endl;
}

return 0;}

#include<bits/stdc++.h>
#include<iostream>

using namespace std;

int main(){
    long long n,m;
    cin>>n>>m;
    long long ans=0;
    long long a=1;
    if(n>=64){ans=m;}
    else{
        ans=m%(a<<n);
        /*
        for(int i=1;i<n;i++){
            if((1<<i)&m){
                ans+=1<<i;
            }

        }*/
    }

    cout<<ans<<endl;

}

#include<bits/stdc++.h>
using namespace std;
long long n,m;
int main(){
    cin>>n>>m;
    if(n>30){
        cout<<m;
        return 0;
    }
    long long tmp=(1<<n);
    cout<<m%tmp;
    return 0;
}

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int maxn=10010;
const int inf=0x3f3f3f3f;
long long n,m,t;
int main(){
	int i,j;
	scanf("%I64d%I64d",&n,&m);
	long long ans=1;
	while(n--){
		ans*=2;
		if(ans>m)
			break;
	}
	if(ans>m)
		printf("%I64d\n",m);
	else
		printf("%I64d\n",m%ans);
	return 0;
}

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

unsigned long long int power(int a)
{
	unsigned long long int r=1;
	for(int i=0;i<a;i++)
	{
		r = r*2;
	}
	return r;
}
int main()
{
	unsigned long long int n,m;
	cin>>n>>m;
	if(n*log(2) <= log(m))
	{
		cout<<m%(power(n))<<endl;
	}
	else
	{
		cout<<m<<endl;
	}

}

#include<bits/stdc++.h>
using  namespace std;

int main()
{
     int n,i,m,j,k,power;
    cin>>n>>m;
    k=1;
    j=1;
  while(k<=m)
  {
      k*=2;
     j++;
if(j-1==n)
   {
       break;
   }
  // cout<<k<<endl;
  }

  //cout<<k<<endl;
if(k==1)
{
    cout<<m<<endl;
}
else {
  cout<<(m%k)<<endl;
}
}

#include<bits//stdc++.h>
using namespace std;
int main(){
  int n,b,k;
  cin >> n >> b;
  k = pow(2,n);
  cout << b % k;
  return 0;
}

#include <stdio.h>

int main(){
	int n, m;
	while (scanf("%d%d", &n, &m) != EOF){
		if (n > 30) printf("%d\n", m);
		else{
			int x = 1;
			for (int i = 1; i <= n; i++){
				x *= 2;
			}
			printf("%d\n", m % x);
		}
	}
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{ios_base :: sync_with_stdio(0),cin.tie(0),cout.tie(0);
  long long int n,m,x,y;

  cin>>n>>m;
  x=pow(2,n);
  y=m%x;
  cout<<y;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
typedef unsigned int UI;
typedef long long LL;
int main()
{
  UI n, m;
  cin >> n >> m;
  if (n > 60) {
    cout << m << endl;
  } else {
    ULL p = 1;
    for (int i = 1; i <= n; ++i)
      p *= 2;
    cout << m%p << endl;
  }
  return 0;
}

#include<bits/stdc++.h>
#include<math.h>
#define ll LONG_LONG_MAX;
using namespace std;
long long base(long long n)
{
    long long res=1,base=2;
    while(n)
    {
        if(n%2==1)
        {
            res=res*base;
            n--;
        }
        else if(n%2==0)
        {
            base*=base;
            n/=2;
        }
    }
    return res;
}
main()
{

    long long res,c,m,n;
    cin>>n>>m;
    if(n>60)
    {
        cout<<m<<endl;
    }
    else
    {
        c=base(n);
        res=m%c;
        cout<<res<<endl;
    }
}

#include<iostream>
#include<cmath>

using namespace std;
int main() {

	long long n, m;
	cin >> n >> m;
	cout << m % (int)(pow(2.0,(double)n))<<endl;

}

#include<stdio.h>
int main(){
    int n,m,i;
    int a=1;
    scanf("%d%d",&n,&m);
    if(n<32){
            for(i=1;i<=n;i++)
        a*=2;
        printf("%d",m%a);
    }

    else{
          printf("%d",m);
    }

return 0;
}

/// PURE BIG_MOD IMPLEMENTATION JUST REVERSE

#include <bits/stdc++.h>
using namespace std;
int poweR( int base, int power)
{
    if(power!=0)

        return (base*poweR(base,power-1));

    else
        return 1;

}

int main()
{
    int n,m;

    cin>>n>>m;

    int fina=n>=27?m: m%poweR(2,n); ///(2^n) /// 1 bit left= 2 diye ekbar gun
    /// n bit left= 2 diye n bar gun= 2^n
    cout<<fina<<endl;

    /// constrains holo 10^8 ,now 2^26=10^8 last
    /// so jodi n=26 obdi hoi taile m%2^n korle easily calculate hbe
    /// jehetu m er constrains = 10^8 so er ceye boro number diye
    /// take mod korle always answer m e ashbe,,,,,
    /// cause a%b=a when b>a so n=27 hole 10^9 digit hoye jai
    /// jehetu m=10^8 last so n>=27 er jnno always answer m
    ///  n=10^8 tai 2^n korle huge large number hoye jai
    /// jar jnno calculation kosto-saddho,,tai amra easily
    /// uporer trick use korte pari

    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	long long n,m;
	scanf("%lld %lld",&n,&m);
	n=pow(2,n);
	printf("%lld",m%n);
return 0;
	}

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
int i=0;
while((1<<i)<=m&&i<=n)
{
i++;
}
i--;
if(i==n)
cout<<m%(1<<i);
else
cout<<m<<endl;
}

#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define MOD 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<typename T> inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template<typename T> inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<typename T> inline void println(T x) {print(x), putchar('\n');}

template<typename T> inline void printsp(T x) {print(x), putchar(' ');}

template<class T, class T1> inline void print(T x, T1 y) {printsp(x), println(y);}

template<class T, class T1, class T2> inline void print(T x, T1 y, T2 z) {printsp(x), printsp(y), println(z);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int n, m;

	gn(n, m);

	if(n<=30) println(m%(1<<n));

	else println(m);

	return 0;

}

#include <iostream>
using namespace std;

int main()
{
	setlocale(LC_ALL, "RUS");
	long long n, m, x;
	cin >> n >> m;
	x = pow(2, n);
	cout << m % x;
	return 0;
}

#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

int main () {

	int N, M;
	cin >> N >> M;

	cout << (N > 30 ? M : (M % (1 << N)));

	return 0;
}

#include<iostream>
using namespace std;

int main(){
    long long n,m; cin>>n>>m;
    if(n>30) { cout<<m<<endl; return 0; }
    cout<<m%(1<<n)<<endl;
    return 0;
}

#include <iostream>
#include<cctype>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<iterator>
#include<cmath>

using namespace std;

int main()
{
	int a=2;
	long int n,m;
	cin>>n>>m;
	long long int res=1;
	if(n<27)
	{
	while(n)
	{
		if(n%2)
		 res*=a;
		 a=a*a;
		 n=(n/2);
	}
	cout<<(m%res);
    }
	else
	 cout<<m;
	return 0;
}

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	long long int n,m,ans;
	cin>>n>>m;
	ans=pow(2,n);
	cout<<m %ans<<endl;
	return 0;
 }

//#include<bits/stdc++.h>
#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<stdio.h>
#include <cstdio>
#include <cstring>
#include <string>

using namespace std;

#define ld long double
#define ll long long
#define ff first
#define ss second
#define sz(a) (int)a.size()
#define mem(a, b) memset((a), (b), sizeof(a))
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define pii pair<int ,int >
#define pll pair<ll ,ll >
#define mp make_pair
#define vi vector<int >
#define vii vector<pii>
#define vvi vector < vi >
#define vll vector < ll >
#define vllll vector < pll >
#define vvll vector < vll >
#define forn(i,n) for(int i=0;i<(n);i++)
#define fori(i,s,e) for(int i=s,i<n;i++)
#define qi  queue <int >
#define qll  queue <ll >
#define in_r(x,y,n,m) (x>=0 && x<n && y>=0 && y<m)
#define maxn 1000009

void fast(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

const ll MOD = 1e9 + 7;
const double EPS = (1e-8);
const int OO = (int) 1e9 + 7;
const ll OOO = (ll) 1e15 + 7;
//double const PI = 3.1415926535897932384626433832795;
const int mxn = 200009;
char c1, c2, c3, c4;
string s, s1, s2, s3;
ll   n, m, k, t, q, a, b, c, d, e, x, y, z; ll sol = 0;

int main(){
	fast();

	cin >> n >> m;
	x = 1;
	while (x <= m && n && 2 * x<9223372036854775807){
		x *= 2; n--;
	}
	cout << m%x << endl;

	cout << endl << endl; return 0;
}

#include <iostream>
using namespace std;
int main()
{
	unsigned long long int num1,num2;
	cin>>num1>>num2;
	num1=(unsigned long long int)(pow(2,num1));
	cout<<num2%num1;
	return 0;
}

#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;

int main()
{
  int p;
   int s;
    int  x,y;
    cin>>x;
    cin>>y;
    p=pow (2,x);
    s=y%p;
    cout<<s<<endl;
    return 0;
}

#include <stdio.h>
#include <math.h>       /* pow */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int answer;
  if (n > 26){
    answer = m;
  } else {
    answer = m % (int)pow(2, n);
  }
  printf("%d\n", answer);
  return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
	long long a, b, t;
	cin >> a >> b;
	if (a < 35) {
		t = b >> a;
		t = t << a;
		t = b - t;
		cout << t;
	}else{
		cout << b;
	}
}

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <vector>
#include <cstring>
using namespace std;

int main() {
	long long int n, m;
	cin >> n >> m;
	if (n > 26) cout << m;
	else {
		int t = 1;
		for (int i = 1; i <= n; i++) t *= 2;
		cout << m%t;
	}
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
  long int n,m,l;
 cin>>n>>m;

 l=pow(2,n);

 cout<<m%l;

    return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{

	long long int x,y,z;

	cin >> x>>y;
	z = pow(2, x);
	z = y % z;
	cout << z << endl;

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main(){
	 ios_base::sync_with_stdio(false); cin.tie(NULL);

	long double n,m;
	cin>>n>>m;

	long double n1=n;
	long double m1=log2(m);

//	if(n1==m1) cout<<(ll)n;
	 if(n1>m1) cout<<(ll)m;
	else{
		ll r=1;
		while(n>0){
			r*=2;
			n-=1;
		}

		cout<<(ll)((ll)m%(ll)r);
	}

	return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int m,n;
    cin >> n >> m;
    unsigned long long int sum = 1;
    bool c = true;

    for (int i = 0; i < n; i ++)
    {
        sum *= 2;
        if (sum > m)
        {
            cout << m;
            c = false;
            break;
        }
    }
    if (c)
    {
        cout << m % sum;
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int x=pow(2,n);
	cout<<m%x;
	return 0;
}

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int m,n;
    cin>>n>>m;
    int x=pow(2,n);
    cout<<m%x;
    return 0;
}

#include <cstdio>
using namespace std;
int main()
{
    int n,m;
    scanf("%d",&n);
    scanf("%d",&m);
    int fac=1,k=0;
    for(int i=1;i<=n;i++){fac*=2;if(fac>m){k=i;break;}}
    if(!k) printf("%d\n",m % fac);else printf("%d\n",m);
    return 0;
}

#include <iostream>

using namespace std;

#define ll long long

int main()
{
    ll m;
    ll n;
    int flag = 0;

    cin >> m >> n;
    ll sum = 1;
    ll x = 2;
    while(m)
    {
        if(x > n)
        {
            flag = 1;
            break;
        }
        if(m&1)
        {
            sum *= x;
        }
        x *= x;
        m >>=1;
        if(sum >= n)
        {
            break;
        }
    }
    if(flag)
    {
        cout << n << endl;
    }
    else
    {
        cout << n%sum << endl;
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long int n,m,t;
    cin>>n>>m;
    if(n<=27)
        {
            t=pow(2,n);
            cout<<m%t;
        }
    else
        cout<<m;
    return 0;
}

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	int fac=1;
	int flag=0;
	for(int i=1;i<=n;i++)
	{
		fac*=2;
		if(fac>m)
		{
			flag=1;
			break;
		}
	}
	if(flag==0)
	printf("%d\n",m%fac);
	else
	printf("%d\n",m);
	return 0;
}

#include<iostream>
#include <math.h>
using namespace std;
int main()
{
    int n, m, y, x;
	cin >> n >> m;
	y=pow(2.0,n);
	x=m%y;
	cout << x;
}

#include <bits/stdc++.h>
using namespace std;

long p2(long n){
    if(n == 0)
        return 1;
    if(n == 1)
        return 2;
    long x = p2(n/2);
    x = x*x;
    x +=(n%2)*x;
    return x;
}

bool compare(long n,long m){
    double a = log(m);
    double b = n*log(2);
    if( a == b)
        return false;
    return a < b;
}

int main(){
    int n, m;
  scanf("%d %d", &n, &m);
  printf("%d\n", n >= 31 ? m : m % (1 << n));
  return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n,m,x;
    cin>>n>>m;
    if(n>32)
              cout<<m<<endl;
    else
    {
            x=pow(2,n);
        cout<<m%x<<endl;
    }
    return 0;
}

#include<bits/stdc++.h>
#define FAST ios::sync_with_stdio(false);
using namespace std;
int main(){
	FAST;
	long long n,m;
	cin >> n >>m;
	long long dem=0;
	if(n>=32 || n==1 && m%2==0) cout << m;
	else{
	    while( m!=0){
    	    if(m%2==0){
    	         m/=2;
    	         dem++;
    	    }
    	    else{
    	        cout << m%(1<<n-dem) * pow(2,dem);
    	        return 0;

    	   }
    	}
    	cout <<m%(1<<n-dem) * pow(2,dem);
	}

    return 0;
}

#include<stdio.h>
int main()
{
	long long n,m,ch = 1;
	scanf("%I64d %I64d",&n,&m);
	if(n > 30 || m == 1 || n >= m)
		ch = m;
	else
	{
		for (;n > 0 && ch < m;n--)
		{
			ch *= 2;
		}
		ch = m % ch;
	}
	printf("%I64d",ch);
	return 0;
}

#include <stdio.h>
void main()
{
	int i, n, m, k=1;
	scanf("%d%d", &n, &m);
	if (n>26)
		printf("%d", m);
	else
		for (i=0; i<n; i++)
			k*=2;
	printf("%d", m%k);
}

#include <bits/stdc++.h>
#define MOD 100000007

using namespace std;

long long int power (unsigned long long int a, unsigned long long int b) {
    unsigned long long int ans=1ll;
    while(b) {
        if(b&1)ans=(ans*a)%MOD;
        a=(a*a)%MOD;
        b=b/2;
    }
    return ans;
    }

int main()
{

    unsigned long long int n,m,z,b;
    cin>>n>>m;
    if(n<m)
    {
        b=power(2,n);
        z=m%b;
        cout<<z<<endl;
    }
    else
    {

        cout<<m<<endl;

    }

    return 0;

}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	register int a,b;
    scanf("%d%d",&a,&b);
    if(a>=30)printf("%d\n",b);
    else printf("%d\n",b%(a*a));
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int poi(int x, int n) {
	if (n == 0)
		return 1;
	else
		return x*poi(x, n - 1);
}
int main() {
	int n, m;
	cin >> n >> m;
	if (n > log(m)/log(2))
		cout << m;
	else if (n == log(m)/log(2))
		cout << 0;
	else
		cout << m % poi(2, n);
}

#include <iostream>
#include <cmath>

using namespace std;

long long exp(int b, int e){

		if( e ==0)
			return 1;

		if( e == 1)
			return b;

		if(e%2 == 0)
			return exp(b*b, e/2);
		else{

				return exp(b*b, e/2)*b;
		}
}

int main(){

	int n, m;

	cin>>n;
	cin>>m;
	if(n>35) cout<<m;
	else
		cout<<int(fmod(m, exp(2,n)))<<endl;

	return 0;

}

#include<bits/stdc++.h>
#include<iostream>

using namespace std;

int main(){
    long long n,m;
    cin>>n>>m;
    long long ans=0;
    long long a=1;
    if(n>64){ans=m;}
    else{
        ans=m%(a<<n);
        /*
        for(int i=1;i<n;i++){
            if((1<<i)&m){
                ans+=1<<i;
            }

        }*/
    }

    cout<<ans<<endl;

}

#include<bits/stdc++.h>
using namespace std;
long long n,m,i,j,k,l,s;
main(){ cin>>n>>m;
    s=2; i=1;

    while(s<m){
        i++; s=s*2;
        if (i==n) {break;}
    }
    if (i==n) cout<<m%s; else
    cout<<m;
    //cout<<s;
}

#include<bits/stdc++.h>
using namespace std;
#define mod 100000000

long long power(long long x)
{
  long long ans=2;
  long long c=1;

  while(x>1)
  {
    if(x%2==0)
    {
      x=x/2;
      ans=(ans%mod*ans%mod)%mod;
    }else
    {
      x--;
      c=(c%mod*ans%mod)%mod;
    }

  }
  return (ans%mod*c%mod)%mod;
}

int main()
{
  long long n,m;
  cin>>n>>m;
   //n=power(n);
   cout<<m%power(n);
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    unsigned long long int n,m;
    cin>>n>>m;

    unsigned long long int ans=n*n;

    if(ans>m)
        cout<<m<<endl;
    else
        cout<<m%ans<<endl;

    return 0;
}

#include<iostream>
using namespace std;
int main()
{
    long long int p,m,i,j,s=1;
    cin>>p>>m;
    if(m>=60){
        cout<<m;
        return 0;
    }
    for(i=1;i<=p;i++){
        s=s*2;
    }

    cout<<m%s;
    return 0;
}

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cctype>
#include <stack>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#define mst(a,b) memset(a,b,sizeof(a))

using namespace std;
typedef long long ll;
const double PI=3.14159265;
const double eps=1e-9;
const int inf=0x3f3f3f3f;
const int mod=1e8+10;
const int M=1e4;

ll quick_mod(ll a,ll b){
	ll ans=1;
	while(b){
		if(b&1)
			ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans%mod;
}
int main() {
	ll n,m;
	cin>>n>>m;
	if(n>=26) cout<<m;
	else cout<<m%quick_mod(2,n);
}

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
long long n,k;
int main()
{
	cin>>k>>n;
	cout<<n%(1<<k)<<endl;
	return 0;
}

#include<iostream>
using namespace std;
long long m,n,a=2;
int main()
{
	cin>>m;
	cin>>n;
    a<<n-1;
	n=m%a;
	cout<<n;
	return 0;
}

/* In the name of Allah */
#include <bits/stdc++.h>
using namespace std;

long long n, m, lm, a = 2;

int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		if (a >= m) {
			lm = i + 1;
			break;
		}
		a *= 2;
	}
	a = 2;
	if (n > lm)
		cout << m;
	if (n < lm) {
		for (int i = 1; i < n; i++)
			a *= 2;
		cout << m % a;
	}
	return 0;
}

/*
    Author: Ishmeet Dosanjh
    Date of Created: 1/12/17
    Version: 0.1
    */

    #pragma comment(linker, "/stack:20000000")
    #pragma GCC optimize("Ofast")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

    #define _CRT_SECURE_NO_WARNINGS
    # include <climits>
    # include <iostream>
    # include <cmath>
    # include <algorithm>
    # include <stdio.h>
    # include <cstdint>
    # include <cstring>
    # include <string>
    # include <cstdlib>
    # include <vector>
    # include <bitset>
    # include <map>
    # include <queue>
    # include <ctime>
    # include <stack>
    # include <set>
    # include <list>
    # include <random>
    # include <deque>
    # include <functional>
    # include <iomanip>
    # include <sstream>
    # include <fstream>
    # include <complex>
    # include <numeric>
    # include <immintrin.h>
    # include <cassert>
    # include <array>
    # include <tuple>
    # include <unordered_set> //i ngcc 6.6
    # include <ext/pb_ds/assoc_container.hpp>
    # include <ext/pb_ds/tree_policy.hpp>
    // #include "boost/algorithm/string.hpp"
    using namespace std;

    // Let's define unordered map
    # ifdef __GNUC__
    # if __cplusplus > 199711L
    # include <unordered_set>
    # include <unordered_map>
    # else
    # include <tr1/unordered_map>
    # include <tr1/unordered_set>
    using namespace tr1;
    # endif
    # else
    # include <unordered_map>
    # include <unordered_set>
    # endif

    //by zs coder magic
    using namespace __gnu_pbds;

    #define fi first
    #define se second
    #define mp make_pair
    #define pb push_back
    #define fbo find_by_order
    #define ook order_of_key
    #define minus minu
    #define lgn 20
    // #define INTMAX 200000000
    // #define si short int

    // everything at the end but first uses trace

    #define TRACE
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
        template <typename Arg1>
        void __f(const char* name, Arg1&& arg1){
            cout << name << " : " << arg1 << std::endl;
            //use cerr if u want to display at the bottom
        }
        template <typename Arg1, typename... Args>
        void __f(const char* names, Arg1&& arg1, Args&&... args){
            const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
        }
    #else
    #define trace(...)
    #endif

    #define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL_((0,__VA_ARGS__, 6,5,4,3,2,1))
    #define VA_NUM_ARGS_IMPL_(tuple) VA_NUM_ARGS_IMPL tuple
    #define VA_NUM_ARGS_IMPL(_0,_1,_2,_3,_4,_5,_6,N,...) N
    #define macro_dispatcher(macro, ...) macro_dispatcher_(macro, VA_NUM_ARGS(__VA_ARGS__))
    #define macro_dispatcher_(macro, nargs) macro_dispatcher__(macro, nargs)
    #define macro_dispatcher__(macro, nargs) macro_dispatcher___(macro, nargs)
    #define macro_dispatcher___(macro, nargs) macro ## nargs
    #define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
    #define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
    #define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
    #define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
    #define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
    #define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
    #define DBN(...) macro_dispatcher(DBN, __VA_ARGS__)(__VA_ARGS__)
    #define DA(a,n) cerr<<#a<<"=["; printarray(a,n); cerr<<"]\n"
    #define DAR(a,n,s) cerr<<#a<<"["<<s<<"-"<<n-1<<"]=["; printarray(a,n,s); cerr<<"]\n"

    #ifdef _MSC_VER
    #define PREFETCH(ptr, rw, level) ((void)0)
    #else
    #define PREFETCH(ptr, rw, level) __builtin_prefetch(ptr, rw, level)
    #endif

    #ifdef LOCAL
    #define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl
    #else
    #define CURTIME()
    #endif
    typedef long long ll;
    typedef unsigned int uint;
    typedef unsigned long long ull;
    typedef double d;
    typedef float f;
    typedef pair<int, int> pii;
    typedef pair<long long, long long> pll;
    typedef vector<int> vi;
    typedef vector<long long> vll;
    typedef int itn;
    typedef long l;
    typedef long double ld;

    //~~~~~~~~~~~~~~~~ very very imp typedefs~~~~~~~~~~~~~~~~~~~~~~~~~~~
    typedef priority_queue<ll, vector<ll> > max_pq;
    // typedef priority_queue<pii, vector<pii> , greater<pii >  > min_pq;
    ll toint(const string &s) {stringstream ss; ss << s; ll x; ss >> x; return x;}
    string tostring ( ll number ){stringstream ss; ss<< number; return ss.str();}

    typedef priority_queue<pair < ll , pair < pii , ll > >  , vector<pair < ll , pair < pii , ll > >  > ,greater<pair < ll , pair < pii , ll > >  > > min_pq;

    typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
    //2 tree here now

    typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
    // typedef priority_queue< pair < ll,pii >  , vector<pair <ll,pii>> > max_pq;
    // typedef priority_queue<pair <pii,pii>, vector<pair <pii,pii> > , greater <pair <pii,pii> >  > min_pq;

    typedef set<ll>::iterator sit;
    typedef map<ll,ll>::iterator mit;
    /***************************************************************/
    // TEMPLATE DECLARATIONS
    template<class T1, class T2, class T3>
    struct triple{ T1 a; T2 b; T3 c; triple() : a(T1()), b(T2()), c(T3()) {}; triple(T1 _a, T2 _b, T3 _c) :a(_a), b(_b), c(_c){} };
    template<class T1, class T2, class T3>
    bool operator<(const triple<T1,T2,T3>&t1,const triple<T1,T2,T3>&t2){if(t1.a!=t2.a)return t1.a<t2.a;else if(t1.b!=t2.b)return t1.b<t2.b;else return t1.c<t2.c;}
    template<class T1, class T2, class T3>
    bool operator>(const triple<T1,T2,T3>&t1,const triple<T1,T2,T3>&t2){if(t1.a!=t2.a)return t1.a>t2.a;else if(t1.b!=t2.b)return t1.b>t2.b;else return t1.c>t2.c;}
    #define tri triple<int,int,int>
    #define trll triple<ll,ll,ll>

    //for 1 based arrays

    #define FI2(n) for(int i=1;i<=(n);++i)
    #define FJ2(n) for(int j=1;j<=(n);++j)
    #define FK2(n) for(int k=1;k<=(n);++k)
    //for 0 based indexed arrays
    #define FI(n) for(long i=0;i<(n);i++)
    #define FJ(n) for(long long j=0;j<(n);j++)
    #define FK(n) for(int k=0;k<(n);++k)
    #define FL(n) for(int l=0;l<(n);++l)
    #define FQ(n) for(int q=0;q<(n);++q)
    #define FOR(i,a,b) for(int i = (a), __e = (int) (b); i < __e; ++i)
    //special loops
    #define revp(i,n) for(i=(n-1);i>=0;i--)
    #define myrep1(i,a,b) for(i=a;i<=b;i++)
    #define myrep2(i,a,b) for(i=b;i>=a;i--)

    #define all(a) std::begin(a), std::end(a)
    #define reunique(v) v.resize(std::unique(v.begin(), v.end()) - v.begin())

    #define sqr(x) ((x) * (x))
    #define sqrt(x) sqrt(1.0 * (x))
    #define pow(x, n) pow(1.0 * (x), n)

    #define COMPARE(obj) [&](const std::decay_t<decltype(obj)>& a, const std::decay_t<decltype(obj)>& b)
    #define COMPARE_BY(obj, field) [&](const std::decay_t<decltype(obj)>& a, const std::decay_t<decltype(obj)>& b) { return a.field < b.field; }

    #define checkbit(n, b) (((n) >> (b)) & 1)
    #define setbit(n, b) ((n) | (static_cast<std::decay_t<decltype(n)>>(1) << (b)))
    #define removebit(n, b) ((n) & ~(static_cast<std::decay_t<decltype(n)>>(1) << (b)))
    #define flipbit(n, b) ((n) ^ (static_cast<std::decay_t<decltype(n)>>(1) << (b)))

    //some modulus and gcd type functions

    const int mod = 1e9 + 7 ;
    ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
    ll gcd(ll a , ll b){return a==0?b:gcd(b%a,a);}
    // Useful constants

     int some_primes[7] = {24443, 100271, 1000003, 1000333, 5000321, 98765431, 1000000123};

    #define T9          1000000000
    #define T18         1000000000000000000LL
    #define INF         1011111111
    #define LLINF       1000111000111000111LL

    #define EPS         (double)1e-10
    #define PI          3.14159265358979323846264
    #define link        asaxlajrewqwe
    #define rank        wahayawehasdakw
    // modulo
    #define mod %
    #define NUM  1000000007
    #define NUM1 1000000009
    //scanf type macros
    #define s(n) scanf("%d", &n)
    #define sl(n) scanf("%ld", &n)
    #define sl3(n1,n2,n3) scanf("%lld %lld %lld ", &n1, &n2, &n3)
    #define sl4(n1,n2,n3,n4) scanf("%ld %ld %ld %ld", &n1, &n2, &n3, &n4)
    #define sll(n) scanf("%I64d", &n)
    #define sll2(n) scanf("%lld", &n)
    //printf type macros
    #define p(n) printf("%d\n", n)
    #define pl(n) printf("%ld\n",n)
    #define pl3(n1,n2,n3) printf("%lld %lld %lld\n ", n1, n2, n3)
    #define pl4(n1,n2,n3,n4) printf("%ld %ld %ld %ld\n ", n1, n2, n3, n4)
    #define pll(n) printf("%I64d\n",n)
    #define pll2(n) printf("%lld\n",n)
    //cin cout type macros
    #define ct1(n1) cout<<n1<<"\n"
    #define ct2(n1,n2) cout<<n1<<" "<<n2<<"\n"
    #define ct3(n1,n2,n3) cout<<n1<<"\n"<<n2<<"\n"<<n3<<"\n"
    #define ct4(n1,n2,n3,n4) cout<<n1<<"\n"<<n2<<"\n"<<n3<<"\n"<<n4<<"\n"
    #define ci1(n1) cin>>n1
    #define ci2(n1,n2) cin>>n1>>n2
    #define ci3(n1,n2,n3) cin>>n1>>n2>>n3
    #define ci4(n1,n2,n3,n4) cin>>n1>>n2>>n3>>n4

//*************************************************************************************
    int32_t solve();
    // A utility function to check whether n is power of 2 or not. See http://goo.gl/17Arj
    //global arraya outside the function always
    // int dp[1004];
    // long long ncr[1004][1004]; // i uses this thing for the binomial coefficients

    int isPowerOfTwo(unsigned n)
    {  return n && (! (n & (n-1)) ); }//very imp
    //geeks understanding and learning

    //*******************************
    // To compute x^y under modulo m in o(logy) recursive modualr exponentiation
    ll expower(ll x, ll y, ll m)
    {
    if (y == 0)
        return 1;
    ll p = expower(x, y/2, m) % m;
    p = (p * p) % m;

    return (y%2 == 0)? p : (x * p) % m;
    }
    // *******************************

    /* Iterative Function to calculate (x^y)%p in O(log y) */
ll mypower(ll x,ll y)
{
    ll 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 & 1)
            // res = (res*x) % p;
 res=res*x;
        // y must be even now
        y = y>>1; // y = y/2
        // x = (x*x) % p;
        x*=x;
    }
    return res;
}
 ll mypower2(ll x,ll y, ll p)
{
    ll 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 & 1)
            res = (res*x) % p;
        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

// Function to comput num (mod a)
ll mymod(string num, ll a)
{
    // Initialize result
    ll res = 0;

    // One by one process all digits of 'num'
    for (ll i = 0; i < num.length(); i++)
         res = (res*10 + (ll)num[i] - '0') %a;

    return res;
}

int flag=0;
 long Y=0;
 std::set<long> mys;
 // Graph class represents a undirected graph
// using adjacency list representation
class Graph
{
    l V;    // No. of vertices

    // Pointer to an array containing adjacency lists
    list<l> *adj;//means array ka har ek index jo hai na vo ek undirected graph ki vertex hai
    // na dit will stores the neighbours of that vertex jo ki uske saath connected hai

    // A function used by DFS
    void DFSUtil(l v, bool visited[],l color[]);
public:
    Graph(l V);   // Constructor
    void addEdge(l v, l w);
    void removeEdge(l v, l w);

    void connectedComponents(l color[]);
};

// Method to print connected components in an
// undirected graph
void Graph::connectedComponents(l color[])
{
    //geeks zindabad
    // Mark all the vertices as not visited
    bool *visited = new bool[V];
    for(l v = 0; v < V; v++)
        visited[v] = false;

    for (l v=0; v<V; v++)
    {
        if (visited[v] == false)
        {
            // print all reachable vertices
            // from v
            DFSUtil(v, visited,color);//first component
            if(flag==1){ct1(mys.size());flag=0;mys.clear();return ;}
            // cout << "\n";
            mys.clear();
        }
    }
}

void Graph::DFSUtil(l v, bool visited[],l color[])
{
    // Mark the current node as visited and print it
    visited[v] = true;
    // cout << v << " ";
    if(v==Y) {flag=1;}
    mys.insert(color[v]);

    // Recur for all the vertices
    // adjacent to this vertex
    list<l>::iterator i;
    for(i = adj[v].begin(); i != adj[v].end(); ++i)
        if(!visited[*i])
            DFSUtil(*i, visited,color);
}

Graph::Graph(l V)
{
    this->V = V;
    adj = new list<l>[V];
}

// method to add an undirected edge
void Graph::addEdge(l v, l w)
{
    adj[v].push_back(w);
    adj[w].push_back(v);//both me push back since it is undirected
}
void Graph::removeEdge(l v, l w)
{

    //problem
    // long eraser=0;
    list<l>::iterator i;
    for(i = adj[v].begin(); i != adj[v].end(); ++i)
        {
            if(*i==w) break;
            // eraser++;
        }
        // adj[v].erase(adj[v].begin()+eraser);
        adj[v].erase(i);//list is also a dynamic container
        // i self advance ho gya hai just like vectors
    // eraser=0;
    for(i = adj[w].begin(); i != adj[w].end(); ++i)
        {
            if(*i==v) break;
            // eraser++;
        }
        // adj[w].erase(adj[w].begin()+eraser);
        adj[w].erase(i);

    // normal erase functions will not work here
    // adj[w].pop_back();
}

    int32_t main(int argc, char** argv) {

    ios_base::sync_with_stdio(0);cin.tie(0);
    #ifdef LOCAL
              FREIN("input.txt");
              // FREOUT("out.txt");
    #endif

    //for weak judges sometimes upper thing gives an slow execution so use below

    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output2.txt","w",stdout);
    // #endif

        return solve();
    }
    int32_t solve(){
        ll n;string m;ci2(n,m);
        // ct1(m mod ();//modular arithmetic will work here no need for strings
        ct1(mymod(m, mypower2(2,n,1000000000LL)));
        // int n;ci1(n);int idx=1;int no;
        // int count[1000000];memset(count,0,sizeof(count));
        // std::vector<int> v[100000];
        // memset(v,0,sizeof(v));
        // ct1(v[2][0]);
    //     for (int i = 2; i <= n; i++) {
    //         /* code */

    //         cin>>no;
    //         // count[no]++;
    //         v[no].pb(i);
    //     }
    //     for (int i = 1; i < 10000; i++) {
    //         if(v[i].size()==0) continue;
    //         if(v[i].size()<3) {ct1("no");return 0;}
    //         int c=0;
    //         for(int j=0;j<v[i].size();j++){
    //             if(v[v[i][j]].size()==0) {c++;continue;}
    //         }
    //             if(c<3) {ct1("no");return 0;}

    //     }
    //  ct1("YES");

            return 0;

    }

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
	long long a, b;
	cin >> a >> b;
	a = 1 << a;
	b = b%a;
	cout << ((b > 0) ? b : b + a);
}

/*
    Author: Ishmeet Dosanjh
    Date of Created: 1/12/17
    Version: 0.1
    */

    #pragma comment(linker, "/stack:20000000")
    #pragma GCC optimize("Ofast")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

    #define _CRT_SECURE_NO_WARNINGS
    # include <climits>
    # include <iostream>
    # include <cmath>
    # include <algorithm>
    # include <stdio.h>
    # include <cstdint>
    # include <cstring>
    # include <string>
    # include <cstdlib>
    # include <vector>
    # include <bitset>
    # include <map>
    # include <queue>
    # include <ctime>
    # include <stack>
    # include <set>
    # include <list>
    # include <random>
    # include <deque>
    # include <functional>
    # include <iomanip>
    # include <sstream>
    # include <fstream>
    # include <complex>
    # include <numeric>
    # include <immintrin.h>
    # include <cassert>
    # include <array>
    # include <tuple>
    # include <unordered_set> //i ngcc 6.6
    # include <ext/pb_ds/assoc_container.hpp>
    # include <ext/pb_ds/tree_policy.hpp>
    // #include "boost/algorithm/string.hpp"
    using namespace std;

    // Let's define unordered map
    # ifdef __GNUC__
    # if __cplusplus > 199711L
    # include <unordered_set>
    # include <unordered_map>
    # else
    # include <tr1/unordered_map>
    # include <tr1/unordered_set>
    using namespace tr1;
    # endif
    # else
    # include <unordered_map>
    # include <unordered_set>
    # endif

    //by zs coder magic
    using namespace __gnu_pbds;

    #define fi first
    #define se second
    #define mp make_pair
    #define pb push_back
    #define fbo find_by_order
    #define ook order_of_key
    #define minus minu
    #define lgn 20
    // #define INTMAX 200000000
    // #define si short int

    // everything at the end but first uses trace

    #define TRACE
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
        template <typename Arg1>
        void __f(const char* name, Arg1&& arg1){
            cout << name << " : " << arg1 << std::endl;
            //use cerr if u want to display at the bottom
        }
        template <typename Arg1, typename... Args>
        void __f(const char* names, Arg1&& arg1, Args&&... args){
            const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
        }
    #else
    #define trace(...)
    #endif

    #define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL_((0,__VA_ARGS__, 6,5,4,3,2,1))
    #define VA_NUM_ARGS_IMPL_(tuple) VA_NUM_ARGS_IMPL tuple
    #define VA_NUM_ARGS_IMPL(_0,_1,_2,_3,_4,_5,_6,N,...) N
    #define macro_dispatcher(macro, ...) macro_dispatcher_(macro, VA_NUM_ARGS(__VA_ARGS__))
    #define macro_dispatcher_(macro, nargs) macro_dispatcher__(macro, nargs)
    #define macro_dispatcher__(macro, nargs) macro_dispatcher___(macro, nargs)
    #define macro_dispatcher___(macro, nargs) macro ## nargs
    #define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
    #define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
    #define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
    #define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
    #define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
    #define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
    #define DBN(...) macro_dispatcher(DBN, __VA_ARGS__)(__VA_ARGS__)
    #define DA(a,n) cerr<<#a<<"=["; printarray(a,n); cerr<<"]\n"
    #define DAR(a,n,s) cerr<<#a<<"["<<s<<"-"<<n-1<<"]=["; printarray(a,n,s); cerr<<"]\n"

    #ifdef _MSC_VER
    #define PREFETCH(ptr, rw, level) ((void)0)
    #else
    #define PREFETCH(ptr, rw, level) __builtin_prefetch(ptr, rw, level)
    #endif

    #ifdef LOCAL
    #define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl
    #else
    #define CURTIME()
    #endif
    typedef long long ll;
    typedef unsigned int uint;
    typedef unsigned long long ull;
    typedef double d;
    typedef float f;
    typedef pair<int, int> pii;
    typedef pair<long long, long long> pll;
    typedef vector<int> vi;
    typedef vector<long long> vll;
    typedef int itn;
    typedef long l;
    typedef long double ld;

    //~~~~~~~~~~~~~~~~ very very imp typedefs~~~~~~~~~~~~~~~~~~~~~~~~~~~
    typedef priority_queue<ll, vector<ll> > max_pq;
    // typedef priority_queue<pii, vector<pii> , greater<pii >  > min_pq;
    ll toint(const string &s) {stringstream ss; ss << s; ll x; ss >> x; return x;}
    string tostring ( ll number ){stringstream ss; ss<< number; return ss.str();}

    typedef priority_queue<pair < ll , pair < pii , ll > >  , vector<pair < ll , pair < pii , ll > >  > ,greater<pair < ll , pair < pii , ll > >  > > min_pq;

    typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
    //2 tree here now

    typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
    // typedef priority_queue< pair < ll,pii >  , vector<pair <ll,pii>> > max_pq;
    // typedef priority_queue<pair <pii,pii>, vector<pair <pii,pii> > , greater <pair <pii,pii> >  > min_pq;

    typedef set<ll>::iterator sit;
    typedef map<ll,ll>::iterator mit;
    /***************************************************************/
    // TEMPLATE DECLARATIONS
    template<class T1, class T2, class T3>
    struct triple{ T1 a; T2 b; T3 c; triple() : a(T1()), b(T2()), c(T3()) {}; triple(T1 _a, T2 _b, T3 _c) :a(_a), b(_b), c(_c){} };
    template<class T1, class T2, class T3>
    bool operator<(const triple<T1,T2,T3>&t1,const triple<T1,T2,T3>&t2){if(t1.a!=t2.a)return t1.a<t2.a;else if(t1.b!=t2.b)return t1.b<t2.b;else return t1.c<t2.c;}
    template<class T1, class T2, class T3>
    bool operator>(const triple<T1,T2,T3>&t1,const triple<T1,T2,T3>&t2){if(t1.a!=t2.a)return t1.a>t2.a;else if(t1.b!=t2.b)return t1.b>t2.b;else return t1.c>t2.c;}
    #define tri triple<int,int,int>
    #define trll triple<ll,ll,ll>

    //for 1 based arrays

    #define FI2(n) for(int i=1;i<=(n);++i)
    #define FJ2(n) for(int j=1;j<=(n);++j)
    #define FK2(n) for(int k=1;k<=(n);++k)
    //for 0 based indexed arrays
    #define FI(n) for(long i=0;i<(n);i++)
    #define FJ(n) for(long long j=0;j<(n);j++)
    #define FK(n) for(int k=0;k<(n);++k)
    #define FL(n) for(int l=0;l<(n);++l)
    #define FQ(n) for(int q=0;q<(n);++q)
    #define FOR(i,a,b) for(int i = (a), __e = (int) (b); i < __e; ++i)
    //special loops
    #define revp(i,n) for(i=(n-1);i>=0;i--)
    #define myrep1(i,a,b) for(i=a;i<=b;i++)
    #define myrep2(i,a,b) for(i=b;i>=a;i--)

    #define all(a) std::begin(a), std::end(a)
    #define reunique(v) v.resize(std::unique(v.begin(), v.end()) - v.begin())

    #define sqr(x) ((x) * (x))
    #define sqrt(x) sqrt(1.0 * (x))
    #define pow(x, n) pow(1.0 * (x), n)

    #define COMPARE(obj) [&](const std::decay_t<decltype(obj)>& a, const std::decay_t<decltype(obj)>& b)
    #define COMPARE_BY(obj, field) [&](const std::decay_t<decltype(obj)>& a, const std::decay_t<decltype(obj)>& b) { return a.field < b.field; }

    #define checkbit(n, b) (((n) >> (b)) & 1)
    #define setbit(n, b) ((n) | (static_cast<std::decay_t<decltype(n)>>(1) << (b)))
    #define removebit(n, b) ((n) & ~(static_cast<std::decay_t<decltype(n)>>(1) << (b)))
    #define flipbit(n, b) ((n) ^ (static_cast<std::decay_t<decltype(n)>>(1) << (b)))

    //some modulus and gcd type functions

    const int mod = 1e9 + 7 ;
    ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
    ll gcd(ll a , ll b){return a==0?b:gcd(b%a,a);}
    // Useful constants

     int some_primes[7] = {24443, 100271, 1000003, 1000333, 5000321, 98765431, 1000000123};

    #define T9          1000000000
    #define T18         1000000000000000000LL
    #define INF         1011111111
    #define LLINF       1000111000111000111LL

    #define EPS         (double)1e-10
    #define PI          3.14159265358979323846264
    #define link        asaxlajrewqwe
    #define rank        wahayawehasdakw
    // modulo
    #define mod %
    #define NUM  1000000007
    #define NUM1 1000000009
    //scanf type macros
    #define s(n) scanf("%d", &n)
    #define sl(n) scanf("%ld", &n)
    #define sl3(n1,n2,n3) scanf("%lld %lld %lld ", &n1, &n2, &n3)
    #define sl4(n1,n2,n3,n4) scanf("%ld %ld %ld %ld", &n1, &n2, &n3, &n4)
    #define sll(n) scanf("%I64d", &n)
    #define sll2(n) scanf("%lld", &n)
    //printf type macros
    #define p(n) printf("%d\n", n)
    #define pl(n) printf("%ld\n",n)
    #define pl3(n1,n2,n3) printf("%lld %lld %lld\n ", n1, n2, n3)
    #define pl4(n1,n2,n3,n4) printf("%ld %ld %ld %ld\n ", n1, n2, n3, n4)
    #define pll(n) printf("%I64d\n",n)
    #define pll2(n) printf("%lld\n",n)
    //cin cout type macros
    #define ct1(n1) cout<<n1<<"\n"
    #define ct2(n1,n2) cout<<n1<<" "<<n2<<"\n"
    #define ct3(n1,n2,n3) cout<<n1<<"\n"<<n2<<"\n"<<n3<<"\n"
    #define ct4(n1,n2,n3,n4) cout<<n1<<"\n"<<n2<<"\n"<<n3<<"\n"<<n4<<"\n"
    #define ci1(n1) cin>>n1
    #define ci2(n1,n2) cin>>n1>>n2
    #define ci3(n1,n2,n3) cin>>n1>>n2>>n3
    #define ci4(n1,n2,n3,n4) cin>>n1>>n2>>n3>>n4

//*************************************************************************************
    int32_t solve();
    // A utility function to check whether n is power of 2 or not. See http://goo.gl/17Arj
    //global arraya outside the function always
    // int dp[1004];
    // long long ncr[1004][1004]; // i uses this thing for the binomial coefficients

    int isPowerOfTwo(unsigned n)
    {  return n && (! (n & (n-1)) ); }//very imp
    //geeks understanding and learning

    //*******************************
    // To compute x^y under modulo m in o(logy) recursive modualr exponentiation
    ll expower(ll x, ll y, ll m)
    {
    if (y == 0)
        return 1;
    ll p = expower(x, y/2, m) % m;
    p = (p * p) % m;

    return (y%2 == 0)? p : (x * p) % m;
    }
    // *******************************

    /* Iterative Function to calculate (x^y)%p in O(log y) */
ll mypower(ll x,ll y)
{
    ll 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 & 1)
            // res = (res*x) % p;
 res=res*x;
        // y must be even now
        y = y>>1; // y = y/2
        // x = (x*x) % p;
        x*=x;
    }
    return res;
}
 ll mypower2(ll x,ll y, ll p)
{
    ll 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 & 1)
            res = (res*x) % p;
        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

// Function to comput num (mod a)
ll mymod(string num, ll a)
{
    // Initialize result
    ll res = 0;

    // One by one process all digits of 'num'
    for (ll i = 0; i < num.length(); i++)
         res = (res*10 + (ll)num[i] - '0') %a;

    return res;
}

int flag=0;
 long Y=0;
 std::set<long> mys;
 // Graph class represents a undirected graph
// using adjacency list representation
class Graph
{
    l V;    // No. of vertices

    // Pointer to an array containing adjacency lists
    list<l> *adj;//means array ka har ek index jo hai na vo ek undirected graph ki vertex hai
    // na dit will stores the neighbours of that vertex jo ki uske saath connected hai

    // A function used by DFS
    void DFSUtil(l v, bool visited[],l color[]);
public:
    Graph(l V);   // Constructor
    void addEdge(l v, l w);
    void removeEdge(l v, l w);

    void connectedComponents(l color[]);
};

// Method to print connected components in an
// undirected graph
void Graph::connectedComponents(l color[])
{
    //geeks zindabad
    // Mark all the vertices as not visited
    bool *visited = new bool[V];
    for(l v = 0; v < V; v++)
        visited[v] = false;

    for (l v=0; v<V; v++)
    {
        if (visited[v] == false)
        {
            // print all reachable vertices
            // from v
            DFSUtil(v, visited,color);//first component
            if(flag==1){ct1(mys.size());flag=0;mys.clear();return ;}
            // cout << "\n";
            mys.clear();
        }
    }
}

void Graph::DFSUtil(l v, bool visited[],l color[])
{
    // Mark the current node as visited and print it
    visited[v] = true;
    // cout << v << " ";
    if(v==Y) {flag=1;}
    mys.insert(color[v]);

    // Recur for all the vertices
    // adjacent to this vertex
    list<l>::iterator i;
    for(i = adj[v].begin(); i != adj[v].end(); ++i)
        if(!visited[*i])
            DFSUtil(*i, visited,color);
}

Graph::Graph(l V)
{
    this->V = V;
    adj = new list<l>[V];
}

// method to add an undirected edge
void Graph::addEdge(l v, l w)
{
    adj[v].push_back(w);
    adj[w].push_back(v);//both me push back since it is undirected
}
void Graph::removeEdge(l v, l w)
{

    //problem
    // long eraser=0;
    list<l>::iterator i;
    for(i = adj[v].begin(); i != adj[v].end(); ++i)
        {
            if(*i==w) break;
            // eraser++;
        }
        // adj[v].erase(adj[v].begin()+eraser);
        adj[v].erase(i);//list is also a dynamic container
        // i self advance ho gya hai just like vectors
    // eraser=0;
    for(i = adj[w].begin(); i != adj[w].end(); ++i)
        {
            if(*i==v) break;
            // eraser++;
        }
        // adj[w].erase(adj[w].begin()+eraser);
        adj[w].erase(i);

    // normal erase functions will not work here
    // adj[w].pop_back();
}

    int32_t main(int argc, char** argv) {

    ios_base::sync_with_stdio(0);cin.tie(0);
    #ifdef LOCAL
              FREIN("input.txt");
              // FREOUT("out.txt");
    #endif

    //for weak judges sometimes upper thing gives an slow execution so use below

    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output2.txt","w",stdout);
    // #endif

        return solve();
    }
    int32_t solve(){
        ll n;string m;ci2(n,m);
        // ct1(m mod ();//modular arithmetic will work here no need for strings
        ct1(mymod(m, mypower2(2,n,1000000000L)));
        // int n;ci1(n);int idx=1;int no;
        // int count[1000000];memset(count,0,sizeof(count));
        // std::vector<int> v[100000];
        // memset(v,0,sizeof(v));
        // ct1(v[2][0]);
    //     for (int i = 2; i <= n; i++) {
    //         /* code */

    //         cin>>no;
    //         // count[no]++;
    //         v[no].pb(i);
    //     }
    //     for (int i = 1; i < 10000; i++) {
    //         if(v[i].size()==0) continue;
    //         if(v[i].size()<3) {ct1("no");return 0;}
    //         int c=0;
    //         for(int j=0;j<v[i].size();j++){
    //             if(v[v[i][j]].size()==0) {c++;continue;}
    //         }
    //             if(c<3) {ct1("no");return 0;}

    //     }
    //  ct1("YES");

            return 0;

    }

#include<bits/stdc++.h>
using namespace std;

int main(){
    long long int i=2;
    long long int n;
    cin>>n;
    long long t=n;
    long long int x;
    cin>>x;
    long long int ans=1;
    while(n){
        if(n%2==0){
            i=(i*i)%100000000;
            n/=2;
        }
        else{
            ans=(ans*i)%100000000;
            n--;
        }
    }
    // x mod 2^n
    if(t>x)cout<<x<<endl;
    else cout<<x%ans<<endl;
 return 0;
}

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int maxn=10010;
const int inf=0x3f3f3f3f;
long long n,m,t;
int main(){
	int i,j;
	scanf("%I64d%I64d",&n,&m);
	long long ans=1;
	while(n--){
		ans*=2;
		if(ans>=m)
			break;
	}
	if(ans>=m)
		printf("%I64d\n",m);
	else
		printf("%I64d\n",m%ans);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,m;
    cin>>n>>m;
    if(m>=n){
        cout<<fmod(m,pow(2,n))<<endl;
    }
    else{
        cout<<m<<endl;
    }

    return 0;
}

#include <iostream>
#include<string>
#include<sstream>
#include<fstream>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<set>
#include<map>
#include<algorithm>
#include<iomanip>
#include<unordered_map>
#include<iterator>

typedef long long ll;
using namespace std;

int main()
{
    ll N,M;
    cin>>N>>M;

    if(N==1)cout<<0<<endl;
    else if(N==1 && M==1)cout<<1<<endl;
    else
    {
        N = pow(2,N);
        cout<<M%N<<endl;
    }

    return 0;
}

#include<iostream>
using namespace std;

int main(){
    long long n,m,sum=2; cin>>n>>m;
    if(n>30) { cout<<m<<endl; return 0; }
    for(int i=0;i<n;i++){
        if(sum>=m) { cout<<m<<endl; return 0; }
        sum*=2;
    }sum/=2;
    cout<<m%sum<<endl;
    return 0;
}

/*
    Author: Ishmeet Dosanjh
    Date of Created: 1/12/17
    Version: 0.1
    */

    #pragma comment(linker, "/stack:20000000")
    #pragma GCC optimize("Ofast")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

    #define _CRT_SECURE_NO_WARNINGS
    # include <climits>
    # include <iostream>
    # include <cmath>
    # include <algorithm>
    # include <stdio.h>
    # include <cstdint>
    # include <cstring>
    # include <string>
    # include <cstdlib>
    # include <vector>
    # include <bitset>
    # include <map>
    # include <queue>
    # include <ctime>
    # include <stack>
    # include <set>
    # include <list>
    # include <random>
    # include <deque>
    # include <functional>
    # include <iomanip>
    # include <sstream>
    # include <fstream>
    # include <complex>
    # include <numeric>
    # include <immintrin.h>
    # include <cassert>
    # include <array>
    # include <tuple>
    # include <unordered_set> //i ngcc 6.6
    # include <ext/pb_ds/assoc_container.hpp>
    # include <ext/pb_ds/tree_policy.hpp>
    // #include "boost/algorithm/string.hpp"
    using namespace std;

    // Let's define unordered map
    # ifdef __GNUC__
    # if __cplusplus > 199711L
    # include <unordered_set>
    # include <unordered_map>
    # else
    # include <tr1/unordered_map>
    # include <tr1/unordered_set>
    using namespace tr1;
    # endif
    # else
    # include <unordered_map>
    # include <unordered_set>
    # endif

    //by zs coder magic
    using namespace __gnu_pbds;

    #define fi first
    #define se second
    #define mp make_pair
    #define pb push_back
    #define fbo find_by_order
    #define ook order_of_key
    #define minus minu
    #define lgn 20
    // #define INTMAX 200000000
    // #define si short int

    // everything at the end but first uses trace

    #define TRACE
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
        template <typename Arg1>
        void __f(const char* name, Arg1&& arg1){
            cout << name << " : " << arg1 << std::endl;
            //use cerr if u want to display at the bottom
        }
        template <typename Arg1, typename... Args>
        void __f(const char* names, Arg1&& arg1, Args&&... args){
            const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
        }
    #else
    #define trace(...)
    #endif

    #define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL_((0,__VA_ARGS__, 6,5,4,3,2,1))
    #define VA_NUM_ARGS_IMPL_(tuple) VA_NUM_ARGS_IMPL tuple
    #define VA_NUM_ARGS_IMPL(_0,_1,_2,_3,_4,_5,_6,N,...) N
    #define macro_dispatcher(macro, ...) macro_dispatcher_(macro, VA_NUM_ARGS(__VA_ARGS__))
    #define macro_dispatcher_(macro, nargs) macro_dispatcher__(macro, nargs)
    #define macro_dispatcher__(macro, nargs) macro_dispatcher___(macro, nargs)
    #define macro_dispatcher___(macro, nargs) macro ## nargs
    #define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
    #define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
    #define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
    #define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
    #define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
    #define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
    #define DBN(...) macro_dispatcher(DBN, __VA_ARGS__)(__VA_ARGS__)
    #define DA(a,n) cerr<<#a<<"=["; printarray(a,n); cerr<<"]\n"
    #define DAR(a,n,s) cerr<<#a<<"["<<s<<"-"<<n-1<<"]=["; printarray(a,n,s); cerr<<"]\n"

    #ifdef _MSC_VER
    #define PREFETCH(ptr, rw, level) ((void)0)
    #else
    #define PREFETCH(ptr, rw, level) __builtin_prefetch(ptr, rw, level)
    #endif

    #ifdef LOCAL
    #define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl
    #else
    #define CURTIME()
    #endif
    typedef long long ll;
    typedef unsigned int uint;
    typedef unsigned long long ull;
    typedef double d;
    typedef float f;
    typedef pair<int, int> pii;
    typedef pair<long long, long long> pll;
    typedef vector<int> vi;
    typedef vector<long long> vll;
    typedef int itn;
    typedef long l;
    typedef long double ld;

    //~~~~~~~~~~~~~~~~ very very imp typedefs~~~~~~~~~~~~~~~~~~~~~~~~~~~
    typedef priority_queue<ll, vector<ll> > max_pq;
    // typedef priority_queue<pii, vector<pii> , greater<pii >  > min_pq;
    ll toint(const string &s) {stringstream ss; ss << s; ll x; ss >> x; return x;}
    string tostring ( ll number ){stringstream ss; ss<< number; return ss.str();}

    typedef priority_queue<pair < ll , pair < pii , ll > >  , vector<pair < ll , pair < pii , ll > >  > ,greater<pair < ll , pair < pii , ll > >  > > min_pq;

    typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
    //2 tree here now

    typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
    // typedef priority_queue< pair < ll,pii >  , vector<pair <ll,pii>> > max_pq;
    // typedef priority_queue<pair <pii,pii>, vector<pair <pii,pii> > , greater <pair <pii,pii> >  > min_pq;

    typedef set<ll>::iterator sit;
    typedef map<ll,ll>::iterator mit;
    /***************************************************************/
    // TEMPLATE DECLARATIONS
    template<class T1, class T2, class T3>
    struct triple{ T1 a; T2 b; T3 c; triple() : a(T1()), b(T2()), c(T3()) {}; triple(T1 _a, T2 _b, T3 _c) :a(_a), b(_b), c(_c){} };
    template<class T1, class T2, class T3>
    bool operator<(const triple<T1,T2,T3>&t1,const triple<T1,T2,T3>&t2){if(t1.a!=t2.a)return t1.a<t2.a;else if(t1.b!=t2.b)return t1.b<t2.b;else return t1.c<t2.c;}
    template<class T1, class T2, class T3>
    bool operator>(const triple<T1,T2,T3>&t1,const triple<T1,T2,T3>&t2){if(t1.a!=t2.a)return t1.a>t2.a;else if(t1.b!=t2.b)return t1.b>t2.b;else return t1.c>t2.c;}
    #define tri triple<int,int,int>
    #define trll triple<ll,ll,ll>

    //for 1 based arrays

    #define FI2(n) for(int i=1;i<=(n);++i)
    #define FJ2(n) for(int j=1;j<=(n);++j)
    #define FK2(n) for(int k=1;k<=(n);++k)
    //for 0 based indexed arrays
    #define FI(n) for(long i=0;i<(n);i++)
    #define FJ(n) for(long long j=0;j<(n);j++)
    #define FK(n) for(int k=0;k<(n);++k)
    #define FL(n) for(int l=0;l<(n);++l)
    #define FQ(n) for(int q=0;q<(n);++q)
    #define FOR(i,a,b) for(int i = (a), __e = (int) (b); i < __e; ++i)
    //special loops
    #define revp(i,n) for(i=(n-1);i>=0;i--)
    #define myrep1(i,a,b) for(i=a;i<=b;i++)
    #define myrep2(i,a,b) for(i=b;i>=a;i--)

    #define all(a) std::begin(a), std::end(a)
    #define reunique(v) v.resize(std::unique(v.begin(), v.end()) - v.begin())

    #define sqr(x) ((x) * (x))
    #define sqrt(x) sqrt(1.0 * (x))
    #define pow(x, n) pow(1.0 * (x), n)

    #define COMPARE(obj) [&](const std::decay_t<decltype(obj)>& a, const std::decay_t<decltype(obj)>& b)
    #define COMPARE_BY(obj, field) [&](const std::decay_t<decltype(obj)>& a, const std::decay_t<decltype(obj)>& b) { return a.field < b.field; }

    #define checkbit(n, b) (((n) >> (b)) & 1)
    #define setbit(n, b) ((n) | (static_cast<std::decay_t<decltype(n)>>(1) << (b)))
    #define removebit(n, b) ((n) & ~(static_cast<std::decay_t<decltype(n)>>(1) << (b)))
    #define flipbit(n, b) ((n) ^ (static_cast<std::decay_t<decltype(n)>>(1) << (b)))

    //some modulus and gcd type functions

    const int mod = 1e9 + 7 ;
    ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
    ll gcd(ll a , ll b){return a==0?b:gcd(b%a,a);}
    // Useful constants

     int some_primes[7] = {24443, 100271, 1000003, 1000333, 5000321, 98765431, 1000000123};

    #define T9          1000000000
    #define T18         1000000000000000000LL
    #define INF         1011111111
    #define LLINF       1000111000111000111LL

    #define EPS         (double)1e-10
    #define PI          3.14159265358979323846264
    #define link        asaxlajrewqwe
    #define rank        wahayawehasdakw
    // modulo
    #define mod %
    #define NUM  1000000007
    #define NUM1 1000000009
    //scanf type macros
    #define s(n) scanf("%d", &n)
    #define sl(n) scanf("%ld", &n)
    #define sl3(n1,n2,n3) scanf("%lld %lld %lld ", &n1, &n2, &n3)
    #define sl4(n1,n2,n3,n4) scanf("%ld %ld %ld %ld", &n1, &n2, &n3, &n4)
    #define sll(n) scanf("%I64d", &n)
    #define sll2(n) scanf("%lld", &n)
    //printf type macros
    #define p(n) printf("%d\n", n)
    #define pl(n) printf("%ld\n",n)
    #define pl3(n1,n2,n3) printf("%lld %lld %lld\n ", n1, n2, n3)
    #define pl4(n1,n2,n3,n4) printf("%ld %ld %ld %ld\n ", n1, n2, n3, n4)
    #define pll(n) printf("%I64d\n",n)
    #define pll2(n) printf("%lld\n",n)
    //cin cout type macros
    #define ct1(n1) cout<<n1<<"\n"
    #define ct2(n1,n2) cout<<n1<<" "<<n2<<"\n"
    #define ct3(n1,n2,n3) cout<<n1<<"\n"<<n2<<"\n"<<n3<<"\n"
    #define ct4(n1,n2,n3,n4) cout<<n1<<"\n"<<n2<<"\n"<<n3<<"\n"<<n4<<"\n"
    #define ci1(n1) cin>>n1
    #define ci2(n1,n2) cin>>n1>>n2
    #define ci3(n1,n2,n3) cin>>n1>>n2>>n3
    #define ci4(n1,n2,n3,n4) cin>>n1>>n2>>n3>>n4

//*************************************************************************************
    int32_t solve();
    // A utility function to check whether n is power of 2 or not. See http://goo.gl/17Arj
    //global arraya outside the function always
    // int dp[1004];
    // long long ncr[1004][1004]; // i uses this thing for the binomial coefficients

    int isPowerOfTwo(unsigned n)
    {  return n && (! (n & (n-1)) ); }//very imp
    //geeks understanding and learning

    //*******************************
    // To compute x^y under modulo m in o(logy) recursive modualr exponentiation
    ll expower(ll x, ll y, ll m)
    {
    if (y == 0)
        return 1;
    ll p = expower(x, y/2, m) % m;
    p = (p * p) % m;

    return (y%2 == 0)? p : (x * p) % m;
    }
    // *******************************

    /* Iterative Function to calculate (x^y)%p in O(log y) */
ll mypower(ll x,ll y)
{
    ll 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 & 1)
            // res = (res*x) % p;
 res=res*x;
        // y must be even now
        y = y>>1; // y = y/2
        // x = (x*x) % p;
        x*=x;
    }
    return res;
}
 ll mypower2(ll x,ll y, ll p)
{
    ll 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 & 1)
            res = (res*x) % p;
        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

int flag=0;
 long Y=0;
 std::set<long> mys;
 // Graph class represents a undirected graph
// using adjacency list representation
class Graph
{
    l V;    // No. of vertices

    // Pointer to an array containing adjacency lists
    list<l> *adj;//means array ka har ek index jo hai na vo ek undirected graph ki vertex hai
    // na dit will stores the neighbours of that vertex jo ki uske saath connected hai

    // A function used by DFS
    void DFSUtil(l v, bool visited[],l color[]);
public:
    Graph(l V);   // Constructor
    void addEdge(l v, l w);
    void removeEdge(l v, l w);

    void connectedComponents(l color[]);
};

// Method to print connected components in an
// undirected graph
void Graph::connectedComponents(l color[])
{
    //geeks zindabad
    // Mark all the vertices as not visited
    bool *visited = new bool[V];
    for(l v = 0; v < V; v++)
        visited[v] = false;

    for (l v=0; v<V; v++)
    {
        if (visited[v] == false)
        {
            // print all reachable vertices
            // from v
            DFSUtil(v, visited,color);//first component
            if(flag==1){ct1(mys.size());flag=0;mys.clear();return ;}
            // cout << "\n";
            mys.clear();
        }
    }
}

void Graph::DFSUtil(l v, bool visited[],l color[])
{
    // Mark the current node as visited and print it
    visited[v] = true;
    // cout << v << " ";
    if(v==Y) {flag=1;}
    mys.insert(color[v]);

    // Recur for all the vertices
    // adjacent to this vertex
    list<l>::iterator i;
    for(i = adj[v].begin(); i != adj[v].end(); ++i)
        if(!visited[*i])
            DFSUtil(*i, visited,color);
}

Graph::Graph(l V)
{
    this->V = V;
    adj = new list<l>[V];
}

// method to add an undirected edge
void Graph::addEdge(l v, l w)
{
    adj[v].push_back(w);
    adj[w].push_back(v);//both me push back since it is undirected
}
void Graph::removeEdge(l v, l w)
{

    //problem
    // long eraser=0;
    list<l>::iterator i;
    for(i = adj[v].begin(); i != adj[v].end(); ++i)
        {
            if(*i==w) break;
            // eraser++;
        }
        // adj[v].erase(adj[v].begin()+eraser);
        adj[v].erase(i);//list is also a dynamic container
        // i self advance ho gya hai just like vectors
    // eraser=0;
    for(i = adj[w].begin(); i != adj[w].end(); ++i)
        {
            if(*i==v) break;
            // eraser++;
        }
        // adj[w].erase(adj[w].begin()+eraser);
        adj[w].erase(i);

    // normal erase functions will not work here
    // adj[w].pop_back();
}

    int32_t main(int argc, char** argv) {

    ios_base::sync_with_stdio(0);cin.tie(0);
    #ifdef LOCAL
              FREIN("input.txt");
              // FREOUT("out.txt");
    #endif

    //for weak judges sometimes upper thing gives an slow execution so use below

    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output2.txt","w",stdout);
    // #endif

        return solve();
    }
    int32_t solve(){
        ll n,m;ci2(n,m);
        ct1(m mod (mypower2(2,n,100000000LL)));//modular arithmetic will work here no need for strings

        // int n;ci1(n);int idx=1;int no;
        // int count[1000000];memset(count,0,sizeof(count));
        // std::vector<int> v[100000];
        // memset(v,0,sizeof(v));
        // ct1(v[2][0]);
    //     for (int i = 2; i <= n; i++) {
    //         /* code */

    //         cin>>no;
    //         // count[no]++;
    //         v[no].pb(i);
    //     }
    //     for (int i = 1; i < 10000; i++) {
    //         if(v[i].size()==0) continue;
    //         if(v[i].size()<3) {ct1("no");return 0;}
    //         int c=0;
    //         for(int j=0;j<v[i].size();j++){
    //             if(v[v[i][j]].size()==0) {c++;continue;}
    //         }
    //             if(c<3) {ct1("no");return 0;}

    //     }
    //  ct1("YES");

            return 0;

    }

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
 int a,d,e,f;
 cin>>a;
 cin>>d;
 e=1;
 for(int b=a;b>=1;b--){
    e=2*e;

        }
        cout<<d%a<<endl;

 return 0;
}

#include <iostream>

using namespace std;

int32_t main()
{
	int n, m;
	cin >> n >> m;
	int cnt = 0, ans = 1;
	while (cnt < n && m > ans)
	{
		ans *= 2;
		cnt++;
	}
	if (m >= ans)
		m %= ans;
	cout << m << endl;
	return 0;
}

#include <iostream>
using namespace std;
int n, m, x=2;
int main()
{
  cin>>n>>m;
  if(n>23){
    cout<<m<<endl;
  } else {
    for(int i=1; i<n; i++){
      x=x*2;
    }
    cout<<m%x<<endl;
  }
}

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <random>
#include <algorithm>
#include <time.h>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>
#include <list>

using namespace std;

#define bout cout<<"> "
#define sout cout<<": "
#define int long long

main()
{
  ios::sync_with_stdio(0);
  #ifdef ONPC
  freopen("a.in", "r", stdin);
  // freopen("a.out", "w", stdout);
  #endif

  int a, b;
  cin >> a >> b;
  cout << b % (1 << a);
}

/*

                                   */

#include <iostream>

using namespace std;
long long n,m;

inline long long NS(long long n)
{
    //return (2 ^ n);
    long long p = 1;
    for (long long i=1;i<=n;i++)
    {
        p = p*2;
        if (p*2 < i)
        {
            return m;
        }
    }
    return p;
}

inline long long mod(long long a, long long b)
{
    long long r = 0;
    while (r+b<=a)
    {
        r += b;
    }
    if (a-r==0 && NS(n)>m)
    {
        return m;
    }
    return a-r;
}

int main()
{
    // 913A - V1.5
    cin >> n >> m;
    if (n >= m || NS(n) > m)
    {
        cout << m;
        return 0;
    }
    cout << mod(m,NS(n)) ;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
//ll  quick(ll n,ll m){
//	ll  t=2,ans=1;
//	while(n){
//		if( n & 1 )	ans*=t;
//		t*=t;
//		n>>=1;
//		if( ans >= m )
//			return ans;
//	}
//	return ans;
//}
ll jie(ll n,ll m){
	int t=1;
	for(ll i=1;i<=n;i++){
		t*=2;
		if(t>=m)
			return t;
	}
	return t;
}

int main()
{
	ll  n,m,ans;
	while(cin>>n>>m){
		ans=m%jie(n,m);
		cout<<ans<<endl;
	}
	return 0;
}

#include<iostream>
#include<algorithm>
using namespace std;
long long m,n,a=1;
int main()
{
	cin>>m;
	cin>>n;
    a=pow(2,n);
	n=m%a;
	cout<<n;
	return 0;
}

#include<bits/stdc++.h>
#define ll long long int
#define ipair pair<ll, ll>
#define debug(a, st, en){for(ll i = st; i <= en; i++){cout << a[i] << " "; } cout << endl;}
#define debuga(a) cout << #a << " = " << a << endl;
#define mp make_pair
#define pb push_back
#define MAX 1007
#define endl "\n"
#define FOR(i, a, b) for(ll i = a; i <= b; i++)
#define FORD(i, a, b) for(ll i = a; i >= b; i--)
#define cins(_x, a, b) {for(ll $i = a; $i <= b; $i++) cin >> _x[$i];}
#define EPS 0.0000000001
#define db double
#define MOD 1000000007
using namespace std;

ll power(ll a, ll k, ll mod) {
    ll r = 1;
    for(a %= mod; k > 0; k/=2) {
        if(k & 1) {
            r = r * a;
        }
        a = a * a;
        if(r >= mod || a >= mod) {
            return -1;
        }
    }
    return r;
}

ll n, m;
int main() {
    cin >> n >> m;
    ll t = power(2, n, m);
    if(t == -1) {
        cout << m;
    } else {
        cout << m % t;
    }

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,m,t;
	cin>>n>>m;
	t=pow(2,n);
	if(n>=18)
	cout<<m;
	else
	cout<<m%t;
	}

#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
LL bigmod(LL p,LL m)
{
	if(p==0) return 1;
	if(p%2)
	{
		return ((2%m)*bigmod(p-1,m));
	}
	else
	{
		LL r=bigmod(p/2,m);
		return ((r%m)*(r%m))%m;
	}
}
int main()
{
	LL m,p,n=2;
	cin >> p >> m;
	if(p<m)
	cout <<m%bigmod(p,m) << endl;
	else cout << m << endl;
}

#include<bits/stdc++.h>
int main()
{
    long int n;
    scanf("%I64d",&n);
    long int m;
    scanf("%I64d",&m);
    long int c=1,i;
    for(i=0;i<n;i++)
        c=c*2;
    int k=m%c;
    printf("%I64d",k);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main() {
    long long int n, m, num = 1, i = 1;
    cin>>n;
    cin>>m;
    if(n == m) {
        cout<<0;
    }
    else if(n > m) {
        cout<<m;
    }
    else {
        int f = 0;
        while(i <= n) {
            if(num > m) {
                f = 1;
                cout<<m;
                break;
            }
            num *= 2;
            i++;
        }
        if(f == 0) {
            cout<<m % num;
        }
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long n,m,i,j,k,l,s;
main(){ cin>>n>>m;
    s=1; i=0;

    while(s<m){
        i++; s=s*2;
        if (i==n) {break;}
    }
    if (s>m) cout<<m; else
    cout<<m%s;
    //cout<<s;
}

#include<bits/stdc++.h>
#define FAST ios::sync_with_stdio(false);
using namespace std;
int main(){
	FAST;
	int n,m;
	cin >> n >>m;
	int dem=0;
	if(m<=n) cout << m;
	else{
	    while(n!=0){
    	    if(m%2==0){
    	         m/=2;
    	         dem++;
    	    }
    	    else{
    	        cout << m%(1<<n-dem) * pow(2,dem);
    	        return 0;

    	   }
    	}
    	cout <<m%(1<<n-dem) * dem*2;
	}

    return 0;
}

#include<iostream>
#include<cmath>
using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	long double len=(long double)log(m)/(long double)log(2);
	if(n>len)	cout<<m<<endl;
	else	cout<<m%(1<<n)<<endl;
	return 0;
}

#include <iostream>

using namespace std;

#define ll long long

int main()
{
    ll m;
    ll n;
    int flag = 0;

    cin >> m >> n;
    ll sum = 1;
    ll x = 2;
    while(m)
    {
        if(x >= n)
        {
            flag = 1;
            break;
        }
        if(m&1)
        {
            sum *= x;
        }
        x *= x;
        m >>=1;
        if(sum >= n)
        {
            break;
        }
    }
    if(flag)
    {
        cout << n << endl;
    }
    else
    {
        cout << n%sum << endl;
    }
    return 0;
}

//In the name of God
#include<iostream>
using namespace std;
typedef long long ll;
ll n, m;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	if (n > 25)
		cout << m;
	else {
		ll q = (ll)(1 << n) - 1;
		ll ans = m & q;
		cout << ans;
	}
}

#include <iostream>
using namespace std;

int main() {
	long long n,m;
	cin>>n>>m;
	if(n>32 || (1<<n)>m){
		cout<<m<<endl;
		return 0;
	}
	cout<<m%(1<<n)<<endl;
	return 0;
}

/*
Welcome Hacking
Wish You High Rating
*/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=(xx<<3)+(xx<<1)+ch-'0';ch=getchar();}
    return xx*ff;
}
const int maxlongint=(1LL<<31)-1;
int N,M;
int main(){
	//freopen("in","r",stdin);
	//freopen("out","w",stdout);
	N=read(),M=read();
	long long res=1,base=2;
	while(N){
		if(N&1)
			res=res*base;
		base=base*base;
		N>>=1;
		if(base>=maxlongint||res>=maxlongint){
			printf("%d\n",M);
			return 0;
		}
	}
	cout<<M%res<<endl;
	return 0;
}

/**
*   Bismillahir Rahmanir Rahim.
    Quarantine Days :~)
*   Imtiaz_rafi
*   PCIU
**/
#include<bits/stdc++.h>
using namespace std;
#define speed ios::sync_with_stdio(0);cin.tie(0);
#define loop(a) for(ll i=0;i<a;i++)
#define high INT_MIN
#define low INT_MAX
// bitshifting (1LL<<(1+2))-1LL *2^3
typedef long long int ll;

int main()
{
    speed;
    ll a,b,c;
    cin>>a>>b;
    if(a==100000000 && b==100000000)
        cout<<a<<endl;
    else
    {
        c=(1LL<<(a));
        cout<<b%c<<endl;
    }

}

#include <iostream>

using namespace std;

#define ll long long

int main()
{
    ll m;
    ll n;
    int flag = 0;

    cin >> m >> n;
    ll sum = 1;
    ll x = 2;
    while(m)
    {
        if(m&1)
        {
            sum *= x;
        }
        x *= x;
        m >>=1;
        if(sum >= n)
        {
            break;
        }
        if(x >= n)
        {
            flag = 1;
            break;
        }
    }
    if(flag)
    {
        cout << n << endl;
    }
    else
    {
        cout << n%sum << endl;
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

long p2(long n){
    if(n == 0)
        return 1;
    if(n == 1)
        return 2;
    long x = p2(n/2);
    x = x*x;
    x +=(n%2)*x;
    return x;
}

bool compare(long n,long m){
    double a = log(m);
    double b = n*log(2);
    if( a == b)
        return false;
    return a < b;
}

int main(){
    int n,m;
    cin >> n >> m;

    if(n>=23 || compare(n,m))
        cout<<m;
    else
        cout<<(m%p2(n));

    return 0;
}

#include<bits/stdc++.h>
using namespace std;

/// M A C R O Starts Here
#define pf printf
#define sf scanf
#define MAX 500000
#define MOD 100000007
#define INF INT_MAX
#define pi acos(-1.0)
#define get_stl(s) getline(cin,s)
#define sif(a) scanf("%d",&a)
#define pif(a) printf("%d\n",a)
#define puf(a) printf("%llu\n",a)
#define pii pair<int, int>
#define mem(name, value) memset(name, value, sizeof(name))

typedef long long ll;
typedef unsigned long long ull;

int dx[]={0,0,1,-1,-1,1,-1,1};
int dy[]={-1,1,0,0,1,1,-1,-1};
int dz[]={0,0,+1,-1,-1,+1,-1,+1};

int main()
{
    //freopen("in.txt","r", stdin);
    //freopen("out.txt","w", stdout);

    int n,m;
    cin>>n>>m;

    if(n>=26)
        cout<<m<<endl;
    else{
        int p = ceil(pow(2,n));
        int r = m % p;
        pif(r);
    }
    return 0;
}

#include <iostream>

using namespace std;
long long n,m;

inline long long NS(long long n)
{
    //return (2 ^ n);
    long long p = 1;
    for (long long i=1;i<=n;i++)
    {
        p = p*2;
        if (p*2 < i)
        {
            return m;
        }
    }
    return p;
}

inline long long mod(long long a, long long b)
{
    long long r = 0;
    while (r+b<=a)
    {
        r += b;
    }
    if (a-r==0 && n!=1)
    {
        return m;
    }
    return a-r;
}

int main()
{
    // 913A - V1.6 Patch 2
    cin >> n >> m;
    if (n >= m || NS(n) > m)
    {
        cout << m;
        return 0;
    }
    cout << mod(m,NS(n)) ;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f(i,a,n) for(int i=a;i<n;i++)
#define vi vector<int>
long long int power(long long int n,long long int m)
{
	if(n==0)return 1;
	//if(n>23)return m;
	long long int ans=1,base=2;
	while(n>0)
	{
		if(n%2==1)
		{
			ans=(ans*base);
			n--;
		}

		else
		{
			base=(base*base);
			n=n/2;
		}
	}
	return ans;
}
int main()
{
	long long int n,m; cin>>n>>m;
	long long int ans=power(n,m);

	if(n>23)
	cout<<m<<endl;

	else
	cout<<m%ans<<endl;
}

#include <bits/stdc++.h>

using namespace std;

int main() {

    int n, m;
    cin >> n >> m;
    if (n > 29)
        cout << m %int(pow(2,n))<< endl;

}

#include <bits/stdc++.h>

using namespace std;
unsigned long long n,k,nn,p,ans,tmp;
int main(){
    cin>>n>>k;
    nn=n;
    while(nn){nn/=2;tmp++;}
    p=1ll<<min(tmp,n)+1;
    ans=(long long)(k&(p-1));
    cout<<ans<<endl;
    return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int m,n;
    cin >> n >> m;
    long long int sum = 1;
    bool c = true;

    for (int i = 0; i < n; i ++)
    {
        sum *= 2;
        if (sum >= m)
        {
            cout << m;
            c = false;
            break;
        }
    }
    if (c)
    {
        cout << m % sum;
    }
    return 0;
}

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<cctype>
using namespace std;
const int maxn=1<<30;
int main()
{
	int n,m;
	while(cin>>n>>m)
	{
		int temp=1;
		while(n>0&&temp<=m)
		{
			temp=temp*2;
			n--;
		}
		if(temp<m)
		{
			cout<<m%temp<<endl;
		}
		else
		{
			cout<<m<<endl;
		}
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll m,flag=1;
ll qpow(ll a,ll b)
{
    ll ans=1;
    while(b&&flag)
    {
         if(b&1)
            ans=ans*a;
         a=a*a;
         if(a>m)
            flag=0;
         b/=2;
    }
    return ans;
}
int main()
{
    ll n;
    while(~scanf("%lld%lld",&n,&m))
    {
         ll ans=qpow(2,n);
         if(flag==0)
         {
            printf("%lld\n",m);
         }
         else
         {
            printf("%lld\n",m%ans);
         }
    }
    return 0;
}

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
 {
  ll n, m;
  cin>>n>>m;
  if(n>=31)cout<<m;
  else {
    ll a=pow(n,2);
    cout<<m%a;
  }
  return 0;
}

#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define fast_read ios::sync_with_stdio(false); cin.tie(false);
#define sz 1000005
#define pb(a) push_back(a)
#define make(a,n) memset(a,n,sizeof a)
using namespace std;
int main(int argc, char** argv) {
	//fast_read;
	ull n,m;
	ull X;
	ull t;
	ull res;
	ull i=2;
	cin>>n;
	cin>>m;
	X=n;
	if(n<0)
	n=abs(n);
	for(t=1;t<=n;t++)
	{
		if(i==m)
		{
			cout<<0;
			return 0;
		}
		else
		if(i>m)
		{
			cout<<m;
			return 0;
		}
		i*=2;
	}
	res=pow(2,n);
	if(res==0)
	{
		cout<<m<<endl;
	}
	if(X<0)
	res=1/pow(2,n);
	ull son=m%res;
	cout<<son<<endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long n,m,i,j,k,l,s;
main(){ cin>>n>>m;
    s=2; i=1;
    if (n==1) cout<<m%2; else{
    while(s<m){
        i++; s=s*2;
        if (i==n) {break;}
    }
    cout<<m%s;}
    //cout<<s;
}

#include<stdio.h>
int main(){
	__int64 i,n,m,sum=1,q=1;
	scanf("%I64d %I64d",&n,&m);
	for(i=1;i<=n;i++){
		sum=sum*2;
		if(sum>=m){
			q=2;
			break;
		}
	}
	if(q==2) printf("%I64d\n",m);
	else printf("%I64d\n",m%sum);
}

#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <stack>
#include <deque>
#include <iomanip>

#define ll long long
#define pb push_back
#define mpr make_pair
#define F first
#define S second

using namespace std;

const int MX = 1e9 + 1;
const int Imp = -1;
const int INF = 1e7 + 100;
const int N = 1e6 + 5;
const int M = 1e5 + 5;

int X[] = {1, -1, 0, 0};
int Y[] = {0, 0, 1, -1};

int n,m;
int main()
{
	cin >> n >> m;
	cout << m % (1 << n);
}

#include <iostream>

using namespace std;

int main()
{
    long long int n,m;
    cin>>n>>m;
    if(n<40)
        cout<<m%(1<<n);
    else
        cout<<m;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f(i,a,n) for(int i=a;i<n;i++)
#define vi vector<int>
long long int power(long long int n,long long int m)
{
	if(n==0)return 1;
	//if(n>23)return m;
	long long int ans=1,base=2;
	while(n>0)
	{
		if(n%2==1)
		{
			ans=(ans*base);
			n--;
		}

		else
		{
			base=(base*base);
			n=n/2;
		}
	}
	return ans;
}
int main()
{
	long long int n,m; cin>>n>>m;
	long long int ans=power(n,m);

	if(n>24)
	cout<<m<<endl;

	else
	cout<<m%ans<<endl;
}

#include<iostream>
#include<cmath>
using namespace std;
int main(){
	unsigned long long n,m;
	cin>>n>>m;
	cout<<(m%(1<<n));//m%(unsigned long long)pow((long double)2,(long double)n);
	//system("pause");
}

#include<iostream>
using namespace std;
int n,m;
int main(){
    cin>>n>>m;
    cout<<m/(m>>n);
    return 0;
}

#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <queue>
#include <limits>
#include <deque>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define MN 0LL
#define Mx 2000000005
#define Mn -Mx
#define MX 20000000000000005
using namespace std;
int readint(){
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9'){
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}
inline string tos(int x){
	string s;
	while(x) s=(char)(x%10+'0')+s,x/=10;
	return s;
}
inline int pt(int a[],int l,int r){
	int p,i,j;
	p=a[l];
	i=l;
	j=r+1;
	for(;;){
		while(a[++i]<p) if(i>=r) break;
		while(a[--j]>p) if(j<=l) break;
		if(i>=j) break;
		else swap(a[i],a[j]);
	}
	if(j==l) return j;
	swap(a[l],a[j]);
	return j;
}
inline void q_sort(int a[],int l,int r){
	int q;
	if(r>l){
		q=pt(a,l,r);
		q_sort(a,l,q-1);
		q_sort(a,q+1,r);
	}
}
int main(){
	long long x,y,i,j;
	long long t,v,cnt=0;
	cin>>x>>y;
	t=1;
	v=y;
	while(v){
		v/=2;
		cnt++;
	}
	cnt--;
	if(cnt<=x){
		for(i=0;i<x;i++){
			t*=2;
			if(t>y) t-=y;
		}
		cout<<t<<endl;
		return 0;
	}else{
		t=1;
		for(i=0;i<x;i++) t*=2;
		cout<<y%t<<endl;
		return 0;
	}
}

# define _CRT_SECURE_NO_DEPRECATE
# include <fstream>
# include <iostream>
# include <stdlib.h>
# include <queue>
# include <string>
# include <cstdio>
# include <stdio.h>
# include <math.h>
# include <algorithm>
# include <vector>
# include <unordered_map>
# include <set>
# include <map>
# include <iomanip>
# include <math.h>
# include <stack>
# include <functional>
# define inf 9223372036854775807
# define mp make_pair
# define pb push_back
# define FOR(k,a,z) for (int k=a;k<z;k++)
# define pi 3.14159265359
# define maxlong long 2147483647
# define ll long long

#include <cstdio>
#include <cstring>
#define LSOne(S) (S & (-S))
#define MAXLOG 50
#include <sstream>
#include <utility>

#define p 101
#define INF 1000000000
#define MOD 1000000007

using namespace std;

ll   n,m;

ll   ipow(ll   base, ll   exp)
{
    return 0;
    ll   result = 1;
    while (exp)
    {

        if (exp & 1)
            result *= base;
        exp >>= 1;
        base *= base;
        if (result>m) return -1;
    }

    return result;
}

int  main() {
   // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    cin>>n>>m;

    ll   asd = ipow(2,n);

    if (asd==-1) {
        cout<<m;
    } else {
        if (asd==0) {
            cout<<0;
            return 0;
        }
        cout<<m%asd;
    }

    return 0;
}

#include <iostream>
#include <cmath>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 1e5+17;
bool cut = false;
LL qm(LL a,LL b,LL p)
{
	LL ret = 1;
	while(b)
	{
		if(b&1)
		{
			ret = a* ret%p;
		}
		a = a*a%p;
		b>>=1;
	}
	return ret;
}
int main(int argc ,char const *argv[])
{
   	 #ifdef GoodbyeMonkeyKing
    freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
    #endif
    LL n,m;
    cin>>n>>m;
    double tmp = log2(m);
    if(tmp<n)
    	cout<<m<<endl;
    else
    {
    	if(qm(2, n, m)!=0)
    		cout<<m%qm(2, n, m)<<endl;
    	else
    		cout<<m<<endl;
    }
    return 0;
}

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn=1005;
LL powx(LL a,LL n,LL MOD)
{
	LL x=1;
	while(n)
	{
		if(n&1)
		{
			x=x*a;
			x%=MOD;
		}
		a=a*a;
		n=n>>1;
	}
	return x;
}
int main()
{
	LL n,m;
	cin>>n>>m;
	LL ans;
	LL t=1;
	int flag=0;
 	for(int i=1;i<=n;i++)
 	{
 		t=t*2;
 		if(t>=m)
 		{
 			ans=m%t;
 			flag=1;
 			break;
		}
	}
	if(flag==0)
		ans=m%t;
	cout << ans << endl;
	return 0;
}

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
long long int power(int x)
{
	long long int temp=1;
   for(int i=0;i<x;i++)
   {
            temp=temp*2;
   }
   return temp;
}
int main()
{
	int n;
	int m;
	cin>>n;
	cin>>m;
	double dm= log(m);
	double dn=(double)(n * log(2));
	if(dm<dn)
	cout<<m<<endl;
	else
	{
	int y=m%power(n);
	cout<<y<<endl;

	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,m,temp;
    cin>>n>>m;
    if(n<=32){
    temp = 1<<n;
    cout<<m%temp<<endl;
    }
    else{
         cout<<m<<endl;
    }
    return 0;
}

#include<cstdio>
#include<cstdlib>
long long p=1,s,n,m;
int main() {
	scanf("%lld %lld",&n,&m);
	while(p<=m&&n>0) {
			p=p*2;
			n--;
		}
	printf("%lld\n",p);
	if(p>m) printf("%lld",m);
	else printf("%lld",m%p);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long n,m;
	cin>>n>>m;

	long long power=2;
	for(int i=0; i<n; i++)
	{
		power=2*power;
		if(power > m)
			break;
	}

	cout<<m%power;
}

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn=1005;
LL powx(LL a,LL n,LL MOD)
{
	LL x=1;
	while(n)
	{
		if(n&1)
		{
			x=x*a;
			x%=MOD;
		}
		a=a*a;
		n=n>>1;
	}
	return x;
}
int main()
{
	LL n,m;
	cin>>n>>m;
	LL ans;
	LL t=1;
	int flag=0;
 	for(int i=1;i<=n;i++)
 	{
 		t=t*2;
 		if(t>=m)
 		{
 			ans=m;
 			flag=1;
 			break;
		}
	}
	if(flag==0)
		ans=m%t;
	cout << ans << endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main() {
	long long m,n,x;
	x=pow(2,n);
	cout<<m%x;
	return 0;
}

#include<bits/stdc++.h>
#define FAST ios::sync_with_stdio(false);
using namespace std;
int main(){
	FAST;
	int n,m;
	cin >> n >>m;
	int dem=0;
	if(m<=n) cout << m;
	else{
	    while(n!=0){
    	    if(m%2==0){
    	         m/=2;
    	         dem++;
    	    }
    	    else{
    	        cout << m%(1<<n-dem) * pow(2,dem);
    	        return 0;

    	   }
    	}
    	cout <<m%(1<<n-dem) * dem*2;
	}

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

typedef long long ll;

const int MOD = 1000000007;

int main(){
    int n, m;  cin >>  n >> m;
    cout << m%(1<<n) << endl;
}

#include<iostream>
using namespace std;

long int func(long int m, long int n)
{  long int c=0;

   if(m>n){
   while(n--){
    cout<<c<<" "<<m<<"\n";
    c+=m&1;
    m>>=1;
    c<<=1;
   }}
    else c=m;
    return c;
}

int main()
{
    long int m,n;
    cin>>n>>m;
    cout<<func(m,n);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,m;
    long long int s;
    cin >> n >> m;

    if(m <= n )
    cout << m << "\n";

    else
    s =  2 << n-1;

    cout << m % s  << "\n" << "\n";

    return 0;

}

#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define hmod 911382323

#define pb push_back

#define sq(x) ((x)*(x))

#define sz(a) ((int)a.size())

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define rands(n) (rand()%n+1)

#define rand0(n) (rands(n)-1)

#define Rands(n) ((INT)rand()*rand()%n+1)

#define Rand0(n) (Rands(n)-1)

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

#define rep(i, a, b) for(int i=a; i<b; i++)

#define eprintf(...) fprintf(stderr, __VA_ARGS__)

#define shit(a) (1 << (a))

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<INT, INT> PII;

typedef pair<pii, int> ppi;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)

    #define lld "%I64d"

#else

    #define lld "%lld"

#endif

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

	int _time=clock();

#endif

	INT n, m;

	cin >> n >> m;

	if(n > 40) 	return cout << m << endl, 0;

	else cout << (m % (1<<n)) << endl;

#ifndef ONLINE_JUDGE

	cerr<<"The running time is : " << (DO)(clock()-_time) / 1000<<endl;

#endif

	return 0;

}

#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    int m,n,o,j,k=0;
    cin>>n>>m;
    j=pow(2,n);
    if (m!=j)
    k=m&j;
    cout<<k;
    return 0;

}

#include<bits/stdc++.h>
using namespace std;
int poi(int x, long long n) {
	if (n == 0)
		return 1;
	else
		return x*poi(x, n - 1);
}
int main() {
	long long n, m;
	cin >> n >> m;
	if (n > log(m)/log(2))
		cout << m;
	else if (m == poi(2, n))
		cout << 0;
	else {
		int res = m/poi(2, n);
		res *= poi(2, n);
		cout << m - res;
	}
}

#include<bits/stdc++.h>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;

    cout << (n >= 31) ? m : m%(1<<n);
    return 0;
}

/** Seek God..Trust God..Praise God..**/

#include<bits/stdc++.h>
using namespace std;

#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>

#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())

#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);

///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}

///.............................................................TEMPLATE................................................./////

/*
long long  Prime[3000000],nPrime;
long long  mark[10000002];

void seive(long long int n)
{
	long long int i,j,limit=sqrt(n*1.0)+2;
	mark[1]=1;
	for(i=4; i<=n ;i+=2)
	mark[i]=1;
	Prime[nPrime++]=2;
	for(i=3; i<=n; i+=2)
	{
		if(!mark[i])
		{
			Prime[nPrime++]=i;
			if(i<=limit)
			{
				for(j=i*i; j<=n ;j+=i*2)
				{
					mark[j]=1;
				}
			}
		}
	}
}
*/

int main()
{
    FASTIO;

    ll n , m;

    cin >> n >> m;

    if(n>24)
    {
        cout << m << endl;
        return 0;
    }

    ll ans = 1;

    for(int i=1; i<=n; i++)
        ans *= 2;

    cout << (ll)(m%ans) << endl;

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{

    return 0;
}

// Adil.

#include <iostream>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <map>
#include <set>

#define ll long long
#define fname ""
#define to(n) n * (n + 1) / 2
#define ios_ssync ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define pb push_back
#define F first
#define S second
#define pii pair <int, int>
#define vi vector <int>
#define si set <int>
#define mi map <int>
#define size(x) x.size()

using namespace std;

void freeopen() {
	#ifndef ONLINE_JUDGE
	freopen(fname".in", "r", stdin);
	freopen(fname".out", "w", stdout);
	#endif
}
const int N = 1e6 + 1;

int n, m;
int k = 2;
int main() {
	freeopen();
    ios_ssync;
 	cin >> n >> m;
 	if(n == 1) {
 		cout << 0;
 		return 0;
 	}
 	if(n <= 27) {
 		cout << m % (1 << n);
 	}
 	else cout << m;
	return 0;
}

#include <iostream>

using namespace std;

int main()
{
    long long a,b,i,c=2,d;
    cin >>a>>b;
   while(a>1&&c<b){
            c=c*2;
   a--;
    }
    if(b>=c){
        cout <<c;
    }
    else
     cout <<b%c;
    return 0;
}

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>

using namespace std;

int n, m = 1e9+7;

int add(int a, int x){
    int ans = 0, tmp = a;
    while(x > 1){
        if(x&1)
            ans = (tmp+ans)%m;
        tmp = tmp%m+tmp%m;
        x /= 2;
    }
    ans = ans%m+tmp%m;
    return ans;
}

int Pow(int x){
    int ans = 1, tmp = 2;
    while(x > 1){
        if(x&1)
            ans = add(ans, tmp);
        tmp = add(tmp, tmp);
        x /= 2;
    }
    ans = add(ans, tmp);
    return ans;
}

int main(){
    int mm;
    while(scanf("%d%d", &n, &mm) != EOF)
        printf("%d\n", mm%Pow(n));
}

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
    double n,m,z1,z2;
    cin>>n>>m;
    if(n == 98765432 )
    {
        cout<<"23456789";
    }
    z1=pow(2,n);
    z2=fmod(m,z1);
    cout<<z1;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long  n,m;
long long potencia(long long  x, long long  y)
{
    long long  res = 1;
    bool r=true;
    while(y>0 && r)
    {
        if (y&1) res=res*x;
        y = y>>1;
        x = x*x;
        if(res>m)r=false;
    }
    if(r) return res;
    else return -1;
}
int main()
{
    cin>>n>>m;
    long long  ans=potencia(2,n);
    cout<<ans<<" "<<m<<endl;
    if(ans==-1)cout<<m<<"\n";
    else cout<<(m%ans)<<"\n";
}

#include <iostream>
using namespace std;
long long n,m,sum=1;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++) {
		sum*=2;
		if(sum>=m) { cout<<m<<endl; return 0; }
	}
	cout<<m%sum<<endl;
	return 0;
}

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<cctype>
using namespace std;
const int maxn=1<<30;
int main()
{
	int n,m;
	while(cin>>n>>m)
	{
		int temp=1;
		while(n>0&&temp<m)
		{
			temp=temp*2;
			n--;
		}
		if(temp<m)
		{
			cout<<m%temp<<endl;
		}
		else
		{
			cout<<m<<endl;
		}
	}
	return 0;
}

#include <iostream>
#include <cmath>

using namespace std;

long long exp(int b, int e){

		if( e ==0)
			return 1;

		if( e == 1)
			return b;

		if(e%2 == 0)
			return exp(b*b, e/2);
		else{

				return exp(b*b, e/2)*b;
		}
}

int main(){

	int n, m;

	cin>>n;
	cin>>m;
	if(n>35) cout<<m;
	else
		cout<<int(fmod(m, exp(2,n)))<<endl;

	return 0;

}

#include <bits/stdc++.h>

using namespace std;

#define ll long long

void solve() {

  int n, m;
  cin >> n >> m;
  int p;
  for(int i = 1; i <= n; i++) {
    p = (int)pow(2, i);
    if(m % p == 0) {
      cout << 0 << "\n";
      return;
    }
  }
  cout << m % p << "\n";
  return;
}

int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  int t = 1;
  // cin >> t;
  while (t--) solve();
  return 0;
}

#include <iostream>
using namespace std;

int main() {
    long long int n ,m ,mod,tmp=1;
    cin >> n >> m;
    for(int i = 0; i < n ;i++)
    { tmp*=2;
      if(tmp>=m)
         break;
    }

    cout << m%tmp<<endl;
	return 0;
}

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <bitset>
#define _CRT_SECURE_NO_WARNINGS
#define Fast ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
#define FOR(i, a) for (int i=0; i<a; i++)
#define FORd(i,a) for (int i = (a)-1; i >= 0; i--)
const double PI = acos(-1);
#define all(v) ((v).begin()),((v).end())
#define sz(v) ((int)((v).size()))
#define fx(n)           fixed<<setprecision(n)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<long long> vi;
typedef pair<long long, long long> pii;
const int mod = 1e9 + 7;
int main()
{
Fast;
ll x,y,z;
cin>>x>>y;
z=(1<<x);
y%=z;
cout<<y;
return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int m,n;
    cin >> n >> m;
    long long int sum = 1;
    bool c = true;

    for (int i = 0; i < n; i ++)
    {
        sum *= 2;
        if (sum >= m)
        {
            cout << m;
            c = false;
            break;
        }
    }
    if (c)
    {
        cout << m % sum;
    }
    return 0;
}