main = do
    ss <- getLine
    let (n,x) = (ns!!0, ns!!1)
                  where ns = map (\x -> read x :: Int) $ words ss
    if n==0 && x==0
        then return ()
        else do
            putStrLn $ show $ solve n x
            main

solve n x = length $ filter (\l -> sum l == x) [[x,y,z] | x<-[1..n], y<-[1..n], z<-[1..n], x<y, y<z]
