program main
  implicit none
  integer(8) :: k, s, x, y, z, res
  read *, k, s
  res = 0
  do x = 0, k
    do y = 0, k
      z = s - x - y
      if (0 <= z .and. z <= k) res = res + 1
    end do
  end do
  print "(i0)", res
end program main
