solve2 [n,x] = length [(a,b,c) | a <- [1..n], b <- [1..n], let c = x - a - b, a < b, b < c, 0 < c, c <= n]
main = do
  dataSet' <- getContents
  let dataSet = map (map read . words) . init $ lines dataSet'
  mapM_ print $ map solve2 dataSet
