input = gets.split(" ")
n = input[0].to_i
x = input[1].to_i
ans = 0
1.upto(n) do |a|
    (a+1).upto(n) do |b|
        (b+1).upto(n) do |c|
            if a != b && b != c && a != c && (a + b + c == x)
                ans += 1
            end
        end
    end
end
puts ans
