$l = [1]
50.times {|i|
  $l[i+1] = $l[i] * 2 + 3
}

$p = [1]
50.times {|i|
  $p[i+1] = $p[i] * 2 + 1
}

def f(n, x)
  # puts "n=#{n} x=#{x}"
  if n == 0
    x
  elsif x <= 0
    0
  elsif x == 1
    0
  elsif x >= $l[n]
    $p[n]
  else
    if x >= $l[n-1] + 2
      y = x - $l[n-1] - 2
      f(n-1, y) + $p[n-1] + 1
    else
      f(n-1, x-1)
    end
  end
end

n,x=gets.split.map(&:to_i)
p f(n, x)