{-# LANGUAGE MultiWayIf #-}

module Main where

import Data.Word (Word64)
import Debug.Trace (trace)

-- abc115D

main :: IO ()
main = do
  [n,x] <- words <$> getLine
  print $ f (read n) (read x)

f :: Int -> Word64 -> Word64
f n x
  | n == 0                   = 1
  | x <= 1                   = 0
  | size (n-1) + 1 >= x      = f (n-1) (x -1)
  | otherwise                = pati n - f n (size n - x)

size :: Int -> Word64
size 0 = 1
size n = 3 + 2 * size (n-1)

pati :: Int -> Word64
pati 0 = 1
pati n = 1 + 2 * pati (n-1)

