import Text.Printf
main = do
  str<-getLine
  let [n,x]=map read $ words $ str::[Int]
  if(n==0 && x==0)
  then return ()
  else do
    putStrLn $ show $ length [1|a<-[1..n],b<-[1..a-1],c<-[1..b-1],a+b+c==x]
    main