main = interact $ unlines . map (show . itp1_7_b . map read . words) . init . lines

itp1_7_b [n,x] = itp1_7_b' 3 n x
 where
  itp1_7_b' a n' x'
   | a == 1 && x' == n' = 1 
   | n' <= 1 = 0
   | x' <= 0 = 0
   | otherwise = itp1_7_b' (a-1) (n'-1) (x'-n') + itp1_7_b' a (n'-1) x'