void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  long n, m; rd(n); rd(m);

  auto k=2L, p=1L;
  while(k<=m) k*=2, p++;
  if(p<=n){writeln(m); return;}
  auto npow2=1L;
  while(n--) npow2*=2;
  writeln(m%npow2);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}
void wr(T...)(T x){
  import std.stdio;
  foreach(e; x) write(e, " ");
  writeln();
}