#include<bits/stdc++.h>
using ll = int_fast64_t;
#define REP(i,b,e) for(ll i=b; i<e; i++)

int main(){
	ll n, k;
	scanf("%ld %ld", &n, &k);
	ll ans = 0;
	REP(ab, 2, 3*n){
		ll cd = ab-k;
		if(cd<2) continue;
		ll l1 = std::max(0l, ab-n), r1 = std::min(ab, 0+n);
		ll l2 = std::max(0l, cd-n), r2 = std::min(cd, 0+n);
		ans += std::max(0l, std::min(ab-1, r1-l1+1)) * std::max(0l, std::min(cd-1, r2-l2+1));
	}
	printf("%ld\n", ans);
	return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
#define rep(i,n) for(ll i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const long double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const ll INF = 1e9;
ll gcd(ll a, ll b) {if(a%b==0)return a;else return gcd(b,a%b);}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main() {
  ll n,k;
  cin >> n >> k;
  
  if(k < 0) k = -k;
  
  vector<ll> f(3*n);
  for(ll i = 2; i <= 2*n; i++) {
    f[i] = min(i-1, 2*n+1-i);
  }
  ll ans = 0;
  for(ll i = 2; i <= 2*n; i++) {
    if(i-k < 2) continue;
    ans += f[i] * f[i-k];
  }

  cout << ans << endl;
}