def dfs(n, x)
  return 0 if S[n] < x
  return 0 if x < 0
  (x-1 < S[n-1]) ? dfs(n-1, x-1) : P[n-1] + 1 + dfs(n-1, x-1-S[n-1]-1)
end

N,X=gets.split.map(&:to_i)

S=*P=Array.new(N+1){0}
P[0]=S[0]=1
N.times do |n|
  P[n+1] += 1+2*P[n]
  S[n+1] += 3+2*S[n]
end

p dfs(N, X)
