#include<bits/stdc++.h>
using namespace std;
inline  long long  mymin(long long  x,long long  y){return  x<y?x:y;}
inline  long long  mymax(long long  x,long long  y){return  x>y?x:y;}
long long  ans,n,k;
inline  long long  fangan(long long  x)
{
	long long l=mymax(1,x-n),r=mymin(n,x-1);
	return  r-l+1;
}
int  main()
{
	cin>>n>>k;
	if(k<0)k=-k;
	long long  ed=n<<1;
	for(long long  i=k+2;i<=ed;i++)ans+=fangan(i)*fangan(i-k);
	printf("%lld\n",ans);
	return  0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,s,n) for(int i = s; i < (int)(n); i++)
#define Rep(i,s,n) for(int i = s-1;i >= (int)(n); i--)

int main() {
	int n, k;
	cin >> n >> k;
	ll ans = 0;
	rep(b, 2, 2 * n + 1) {
		int a = k + b;
		if (a >= 2 && a <= 2 * n) {
			ll ta, tb;
			if (b <= n) tb = b - 1;
			else tb = 2 * n + 1 - b;
			if (a <= n) ta = a - 1;
			else ta = 2 * n + 1 - a;
			ans += tb * ta;
		}
	}
	cout << ans << endl;
}