solve :: [Int] -> [Int]
solve (x:y:xs)
  | null xs = []
  | otherwise =	length [1 | a<-[1..x], b<-[1..a], c<-[1..b], a /= b && b /= c && c /= a, a+b+c == y] : solve xs

main = getContents >>= print . solve . map read . words