let cs, ps = Array.(make 51 1, make 51 1)
let rec f n k = if k <= 0 then 0 else if n = 0 then 1 else if k <= 1 then 0 else if k >= cs.(n) - 1 then ps.(n) else f (n - 1) (k - 1) + (if k >= cs.(n - 1) + 2 then 1 else 0) + f (n - 1) (k - (cs.(n - 1) + 2))
let _ = for i = 1 to 50 do cs.(i) <- 2 * cs.(i - 1) + 3; ps.(i) <- 2 * ps.(i - 1) + 1 done; Scanf.scanf "%d %d" @@ fun n x -> Printf.printf "%d\n" @@ f n x