
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first 
#define b second
//#define endl '\n'

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	llo n,k;
	cin>>n>>k;
	llo mod=998244353;
	llo ans=0;
	for(llo i=2;i<=2*n;i++){
		llo j=i-k;
		if(j<2 or j>2*n){
			continue;
		}
		llo val1=(i-1)-2*max(i-n-1,(llo)0);
		llo val2=(j-1)-2*max(j-n-1,(llo)0);
		ans+=val1*val2;
		//cout<<i<<","<<j<<','<<val1<<','<<val2<<endl;
	}
	cout<<ans<<endl;




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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
template<typename T>
typedef tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define cntleadz(x) __builtin_clz(x) // or add ll at the end for long long
#define cnttrailz(x) __builtin_ctx(x)
#define cntpop(x) __builtin_popcount(x)
#define binparity(x) __builtin_parity(x)
#define pb push_back
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 998244353//1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)

int binExp(int x,int n)
{
    int res=1;
    while(n)
    {
        if(n&1) res=(res*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return res;
}

// int fact[100001];
// int modInv(int i) {return binExp(i,mod-2);}
// int ncr(int n,int r) {return (n>=r?(fact[n]*modInv(fact[r]))%mod*modInv(fact[n-r])%mod:0);}

void solve()
{
    int n,k;
    cin>>n>>k;

    int an = 0;

    if(k < 0) k = -k;
    f1(i,2,2*n)
    {
        if(i + k > 2*n) break;
        // cout<<"i "<<i<<'\n';

        int ans;

        if(i < n+2)
        {
            ans = (i-2+1);
        }
        else
        {
            int extra = i - n;

            extra = n - extra;
            ans = extra+1;
        }

        int ans2;
        if(i+k < n+2)
        {
            ans2 = (i-2+k+1);
        }
        else
        {
            int extra = i+k - n;

            extra = n - extra;
            ans2 = extra+1;
        }

        an += ans*ans2;
        
        // cout<<i<<' '<<ans<<' '<<ans2<<'\n';
    }

    cout<<an;
}

signed main()
{
    fast

    clock_t start,end;
    #ifndef ONLINE_JUDGE
        freopen("inputf.txt","r",stdin);
        freopen("outputf.txt","w",stdout);
    #endif
    start = clock();

    // test
    solve();

    end = clock();
    double time_taken = double(end-start) / double(CLOCKS_PER_SEC);
    // cout<<time_taken<<" sec";
}