MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end
def bs(ar,eq,n) en=(eq==1 ? :>= : :>); ar.bsearch_index{|x|x.send(en,n)} end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n, x = gsmi

pat = Array.new(n+1,0)
pat[0] = 1
prev = pat[0]
1.upto(n) do |i|
  pat[i] = prev*2+1
  prev = pat[i]
end
all = Array.new(n+1,0)
all[0] = 1
prev = all[0]
1.upto(n) do |i|
  all[i] = prev*2+3
  prev = all[i]
end
# debug 'p',pat.to_s
# debug 'all',all.to_s

# xがN,N-1...1バーガの中心より左,右にあるか判断する
i = n
pos = x
while 0<i do
  cen = all[i]/2+1
  if pos==cen
    cnt+=pat[i-1]+1
    break
  elsif pos>cen
    cnt+=pat[i-1]+1
    i-=1
    pos-=cen
  else
    i-=1
    pos-=1
  end

  # debug 'i',i
  # debug 'pos',pos
  if i==0&&pos>=1
    cnt+=1
  end
end

puts cnt
