main = mapM_ process . takeWhile (/= "0 0") . lines =<< getContents
  where process line = do
                          putStrLn $ show $ length [(a,b,c) | a<- [1..n], b<-[1..n], c<-[1..n], a<b, b<c, a+b+c==x]
                          where [n,x] = map (read::String->Int) $ words line