#include<bits/stdc++.h>
using ll = int_fast64_t;
#define REP(i,b,e) for(ll i=b; i<e; i++)

int main(){
	ll n, k;
	scanf("%ld %ld", &n, &k);
	ll ans = 0;
	REP(ab, 2, 3*n){
		ll cd = ab-k;
		if(cd<2) continue;
		ll l1 = std::max(0l, ab-n), r1 = std::min(ab, 0+n);
		ll l2 = std::max(0l, cd-n), r2 = std::min(cd, 0+n);
		ans += std::max(0l, std::min(ab-1, r1-l1+1)) * std::max(0l, std::min(cd-1, r2-l2+1));
	}
	printf("%ld\n", ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define fi(i,n) for(int i=0;i<n;i++)
#define f(i, a, b) for(int i=a;i<b;i++)
#define vi vector<int>
#define pb push_back
#define MOD 998244353
#define pii pair<int, int>
#define ff first
#define ss second
#define setzero(a) memset(a,0,sizeof(a))

ll digits(ll n)
{
    return floor(log10(double(n))) + 1;
}
void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
ll modularExponentiation(ll x,ll n,ll M)
{
    ll result = 1;
    while(n>0)
    {
        if(n % 2 ==1)
        {
            result = ((result%M)*(x%M))%M;
        }
        x  = ((x%M)*(x%M))%M;
        n = n/2;
    }
    return result%M;
}
ll d, x, y;
void extendedEuclid(ll A, ll B)
{
    if(B == 0)
    {
        d = A;
        x = 1;
        y = 0;
    }
    else
    {
        extendedEuclid(B, A%B);
        int temp = x;
        x = y;
        y = temp - (A/B)*y;
    }
}
// DP solution for nCr
ll nCrModp(ll n, ll r)
{
    if (r > n - r)
        r = n - r;
    ll C[r + 1];
    memset(C, 0, sizeof(C));

    C[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i,r); j > 0; j--)
        {
            C[j] = (C[j] + C[j - 1]);
        }

    }
    return C[r];
}
ll modInverse(ll A, ll M)
{
    extendedEuclid(A,M);
    return (x%M+M)%M;    //x may be negative
}
// primefactors[a] = primefactors[a/primedivisor[a]] + 1
ll sumdigits(ll n)
{
    ll ans = 0;
    while(n>0)
    {
        ans += n%10;
        n = n/10;
    }
    return ans;
}
ll less_power2(ll n)
{
    ll i = 1;
    while(i*2<=n)
    {
        i = i*2;
    }
    return i;
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}
int main()
{
    ll n,k;
    cin>>n>>k;
    ll arr[2*n + 1];
    arr[0] = 0;
    arr[1] = 0;
    ll i = 1;
    for(ll j = 2;j<(2 + n);j++)
    {
        arr[j] = i;
        i++;
    }
    i = n - 1;
    for(ll j = n + 2;j<=2*n;j++)
    {
        arr[j] = i;
        i--;
    }
    ll ans = 0;
    for(ll i = 2;i<=2*n;i++)
    {
        ll sol1 = k + i;
        ll freq1 = arr[i];
        if(sol1<= 2*n && sol1>=2)
        {
            ll freq2 = arr[sol1];
            ans += freq1*freq2;
        }
    }
    cout<<ans;
}
