// < Rahil Malhotra / ViciousCoder >
#include "bits/stdc++.h"
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int n,k;
int tree[2000005];
int lazy[2000005];
void propogate(int i,int l,int r)
{
    tree[i]+=(r-l+1)*lazy[i];
    if(l!=r)
        lazy[i*2]+=lazy[i],lazy[i*2+1]+=lazy[i];
    lazy[i]=0;
}
void update(int i,int l,int r,int l1,int r1,int val)
{
    if(lazy[i])
        propogate(i,l,r);
    if(l1>r1 || l>r1 || l1>r)
        return;
    if(l1<=l && r<=r1)
    {
        tree[i]+=(r-l+1)*val;
        if(l!=r)
            lazy[i*2]+=val,lazy[i*2+1]+=val;
        return;
    }
    int mid=(l+r)/2;
    update(i*2,l,mid,l1,r1,val);
    update(i*2+1,mid+1,r,l1,r1,val);
    tree[i]=tree[i*2]+tree[i*2+1];
}
int query(int i,int l,int r,int l1,int r1)
{
    if(l1>r1 || l>r1 || l1>r)
        return 0;
    if(lazy[i])
        propogate(i,l,r);
    if(l1<=l && r<=r1)
        return tree[i];
    int mid=(l+r)/2;
    return query(i*2,l,mid,l1,r1)+query(i*2+1,mid+1,r,l1,r1);
}
int32_t main() 
{
    IOS;
    cin>>n>>k;
    int ans=0;
    for(int i=1;i<=n;i++)
        update(1,1,2*n+2,i+1,i+n,1);
    for(int i=2;i<=2*n;i++)
    {
        int left=i-k;
        if(left<2 || left>2*n)
            continue;
        // int ways=abs(left)-1;
        // int ways2=abs(i)-1;
        // ans+=ways*ways2;
        // print(i,ways,ways2,left,ways*ways2);
        ans+=query(1,1,2*n+2,i,i)*query(1,1,2*n+2,left,left);
    }
    cout<<ans;
} 
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,n,a) for (int i=n;i>=a;i--)
#define mst(a,i) memset(a,i,sizeof a)
#define ll long long
#define pb push_back
#define eps 1e-10 
#define fi first
#define se second
#define pii pair<int,int> 
#define inf 0x3f3f3f3f 
const int mod = 1000000007;
const int N = 2e5+6;
	ll n,k,tot;
	
ll g(ll e)
{
	if(e>=2&&e<=n+1)return e-1;
	return 2*n-e+1;
}

int main()
{
	std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin>>n>>k;
	ll x,y;
	if(k>=0)
	{
		x=k+2;y=2*n;
	}
	else
	{
		x=2;
		y=2*n+k;
	}
	rep(i,x,y)
	{
		ll e1=i;
		ll e2=i-k;
		tot+=g(e1)*g(e2);
	}
	cout<<tot;
}