import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  [k,s] <- map (read::String->Int) . words <$> getLine
  let l1 = (*3) $ length [(x,y,z)|x<-[0..k], y<-[x+1..k], z<-[y+1..k], x+y+z==s]
  let l2 = length [(x,y,z)|x<-[0..k], y<-[0..k], z<-[0..k], x==y, y==z, x+y+z==s]
  print $ l1+l2