#include <bits/stdc++.h>
using namespace std;

template <typename T>
int len(const T& a) {
	return a.size();
}
using ll = long long;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr);
	int n, k;
	cin >> n >> k;
	long long ans = 0;
	for (int i = -400000; i <= 400000; ++i) {
		if (abs(k - i) > n - 1 || abs(i) > n - 1)
			continue;
		ans += 1ll * abs(n - abs(i)) * abs(n - abs(k - i));
	}
	cout << ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define cs const 
#define fr first 
#define se second
#define ls (now<<1)
#define rs (now<<1|1)
#define mid ((l+r)>>1)
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define low(i) (i&(-i))
#define par pair<int,int>
#define cn(x) memset(x, 0, sizeof(x))
#define rep(i, x, y) for(int i=x; i<=y; ++i)
#define sep(i, x, y) for(int i=x; i>=y; --i)
#define fore(i, x) for(int i=fir[x]; i; i=nex[i])


cs int G = 3;
cs int ff = 1e6 + 15;
cs int inf = 1e18 + 1;
cs int base = 4;
cs int M = 998244353;

void Add(int &x, int y) { x = (x + y) % M; if(x < 0) x += M; }

int ksm(int x, int y) { return (y % 2 == 1 ? x : 1) * (y ? ksm(x * x % M, y >> 1) : 1) % M; }

int n, k;
int calc(int x) 
{ 
	if(x <= 0 || x > n + n) return 0; 
	if(x <= n) return x - 1;
	return n + n + 1 - x;
}
void init()
{
	cin >> n >> k; int Ans = 0;
	rep(i, 1, n + n + n) Ans = Ans + calc(i) * calc(i - k);
	cout << Ans;
}
signed main()
{
//	freopen("triad.in", "r", stdin);
//	freopen("triad.out", "w", stdout);
	int Ts = 1;
	while(Ts--)
		init();
	
}
/*

*/