main = do
  s <- getLine
  let [n,x] = map (read::String->Int) . words $ s
  if n /= 0 || x /= 0 then do
      putStrLn . show . sum $ [ length [max (i+1) (x-i-n)..min n ((x-i+1) `div` 2) - 1] | i <- [1.. min (n-1) (x `div` 3) - 1]]
      main
  else
      return ()