import Control.Applicative
import Control.Monad

main = do
    n:x:_ <- map read .words <$> getLine ::IO[Int]
    if (n > 0 || x > 0) 
      then do 
        putStrLn $ show (length [(a,b,c)| c <- [3..n], b <- [2..c-1], a <- [1..b-1], a+b+c == x ])
        main
      else return()