import Control.Applicative

main = do xs <- map (map read . words) . lines <$> getContents
          putStr . unlines . filter (/= "") $ map solve xs

solve :: [Int] -> String
solve (n:x:_) | n==0 && x==0 = ""
              | otherwise = show $ sum [1| a<-[1..n],b<-[(a+1)..n],c<-[(b+1)..n], a+b+c == x]    