main = do
  s <- getContents
  let v = takeWhile(\x-> x /= [0,0]) $ (map (map (read :: String->Int) . words)) $ lines s
  mapM_ (putStrLn . show . calc)  v

calc :: [Int] -> Int
calc [n,x] = length $ filter ((== x) . sum) $ [[x,y,z]|x<-[1..n],y<-[1..(x-1)],z<-[1..(y-1)]] 