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

def pn(n)
	(2**(n+1))-1
end

def loopn(n,x)
	s = pn(n)
	case x
		when 0..1        then return 0
		when 2...s-1     then return loopn(n-1,x-1)
		when s-1         then return pn(n-1)
		when s           then return pn(n-1)+1
		when s+1...s*2-1 then return pn(n-1)+loopn(n-1,x-s)+1
		else                  return s
	end
end

p loopn(n,x)