let calc n =
    let rec _calc n a =
        if n <= 1
        then a
        else
            match a with
              ((t, p) :: _) -> _calc (n - 1) ((2 * t + 3, 2 * p + 1) :: a)
            | _ -> [] in
    _calc n [(1, 1)];;

let solve table x =
    let rec _solve table x a =
        match table with
          [] -> (a + (if x <= 0 then 0 else 1))
        | ((t, p) :: rs) ->
                if x <= 1 + t
                then _solve rs (x - 1) a
                else _solve rs (x - 2 - t) (a + p + 1) in
    _solve table x 0;;



let () =
    let (n, x) = Scanf.scanf "%d %d" (fun n x -> n, x) in
    let table = calc n in
    print_int (solve table x);
    print_newline ();;

