#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
#define F(index,start,end) for(ll index=start;index<end;++index)
#define IA(array,size) F(index,0,size) cin >> array[index]
#define IA2(array,height,width) F(i,0,height) F(j,0,width) cin >> array[i][j]
#define PA(array,size) F(index,0,size) cout << array[index] << " "; cout << endl
#define PA2(array,height,width) F(i,0,height) {F(j,0,width) cout << array[i][j]; cout << endl;}
#define P(str) cout << str << endl
constexpr int32_t MOD=1000000007;

int main(){
    ll n,k;
    cin>>n>>k;
    if(k<0) k*=-1;
    ll ans=0;
    F(i,2,2*n+1){
        ll j=i-k;
        if(j<2) continue;
        ll p=i-1,q=j-1;
        if(p>n) p=2*n-p;
        if(q>n) q=2*n-q;
        ans+=p*q;
    }
    P(ans);
    return 0;
}
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define Test(tt) cout << "Case #" << tt << ": "
 
 
using namespace std;


const int MOD = 998244353;


int main() {
#ifdef HOME
    ifstream cin("A.in");
    ofstream cout("A.out");
#endif
    int n, k;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n >> k;
    k = abs(k);

    auto get = [](int sum, int n) {
    	int l = max(sum - n, 1);
    	int r = min(sum - 1, n);
    	return r - l + 1;
    };

    ll ans = 0;
    for(int suma = k + 2; suma <= 2 * n; suma++) {
    	ans += 1LL * get(suma, n) * get(suma - k, n);
    }
    cout << ans;

    return 0;
}

