local k, s = io.read("*n", "*n")
local ret = (s + 2) * (s + 1) // 2
if k + 1 <= s then
  local a = s - (k + 1)
  ret = ret - 3 * (a + 2) * (a + 1) // 2
end
if 2 * (k + 1) <= s then
  local a = s - 2 * (k + 1)
  ret = ret + 3 * (a + 2) * (a + 1) // 2
end
if 3 * (k + 1) <= s then
  local a = s - 3 * (k + 1)
  ret = ret - (a + 2) * (a + 1) // 2
end
print(ret)
