ans' k n =
  if 2 * k < n
  then 0
  else
    if k >= n
    then n+1
    else k - (n-k) + 1

ans k s = 
  let xs = [0..k]
      o = sum $ map (\i -> ans' k (s-i) ) xs
  in
    o
        

main = do
  c <- getLine
  let (k:s:_) = map read $ words c :: [Int]
      o = ans k s
  print o
 
