Option Strict On
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim K As Integer = NextInt()
        Dim S As Integer = NextInt()

        Dim ans As Integer = 0

        For x As Integer = 0 To K
            For y As Integer = 0 To K
                Dim z As Integer = S - x - y

                If 0 <= z AndAlso z <= K Then
                    ans += 1
                End If
            Next
        Next

        WriteLine(ans)
    End Sub

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module
