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

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