import Control.Applicative
import Control.Monad

solver :: Int -> Int -> Int
solver n x =
  let cand = [(y1, y2, y3) | y1 <- [1..n], y2 <-[1..(y1-1)], y3 <- [1..(y2-1)],
              y1 + y2 + y3 == x]
  in
      length cand

main :: IO()
main = do
  (n:x:_) <- map (read :: String -> Int) . words <$> getLine
  unless (n == 0 && x == 0) $ do
    print $ solver n x
    main