let num, patty = begin
  let num = Array.make 51 1 in
  let patty = Array.make 51 1 in
  for i = 1 to 50 do
    num.(i) <- 2 * num.(i-1) + 3;
    patty.(i) <- 2 * patty.(i-1) + 1
  done;
  num, patty
end

let rec eat n x =
  if x = 0 then 0 else if n = 0 then 1
  else if x >= num.(n) - 1 then patty.(n)
  else if x >= 2 + num.(n-1) then
    patty.(n-1) + 1 + eat (n-1) (x - 2 - num.(n-1)) 
  else
    eat (n-1) (x-1)

let () =
  Scanf.scanf "%d %d" eat |> Printf.printf "%d\n"


