#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define fill(arr,c) memset(arr,c,sizeof(arr))
#define perm(r) next_permutation(all(r))
//it gives bool value ans permute the string lexoggraphically
#define sortdesc greater<int>()
#define ll long long int 
//std::setfill('0') << std::setw(5) << 25; it adds leaing zeroes;
#define f(i,a) for(int i=0;i<a;i++)
#define fo(i,a) for(int i=1;i<=a;i++)
#define foo(i,x,n,c) for(ll i=x;i<n;i+=c)
#define foi(i,x,n,c) for(ll i=x;i>=n;i+=c)
#define fauto(i,m) for(auto i:m)
#define forall(a) for( auto itr=a.begin();itr!=a.end();itr++)
#define ld long double
#define in push_back
#define mll map<ll,ll>
#define mcl map<char,ll>
#define msl map<string,ll>
#define vi vector<int >
#define vl vector<ll >
#define vp vector< pair<int,int> >
#define vs vector <string> 
#define vc vector <char> 
#define o(a) cout<<a
#define os(a) cout<<a<<" "
#define en cout<<"\n";
#define testcase ll t ;cin>>t; while(t--)
#define ff first
#define ss second
#define pl pair<ll,ll>
#define pi pair<int,int>
#define all(a) (a).begin(), (a).end()

#define sz(a)  (a).size()
#define prec(n) fixed<<setprecision(n)
#define mp make_pair
#define bitcount  __builtin_popcountll
#define imin o("imin");en;
using namespace std;
bool comp(const pair<int,int> &a , const pair<int,int> &b){
    if(a.first == b.first)  return a.second < b.second;
     return a.first < b.first;
}
bool comps(const pair<int,int> &a , const pair<int,int> &b){
    if(a.second == b.second)  return a.first< b.first;
     return a.second < b.second;
}
//ll pi=acos(0.0)*2;
void fastio()
{
    	ios::sync_with_stdio(0);
cin.tie(0);

}
void inout()
{

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);

     freopen("output.txt", "w", stdout);
     #endif
}
ll gcd(ll bb,ll aa)
{
	
	if(bb==0)
	return aa;
	else
	return gcd(aa%bb,bb);
}
ll N=1e9+7;
int main()
{
fastio();
ll n,k;
cin>>n>>k;
ll x,y;
ll ans=0;
foo(i,2,2*n+1,1)
{
	if(i-k>=2 && i-k<=2*n)
	ans=ans+(min(i-1,2*n-i+1))*min(i-1-k,2*n-i+1+k);
}

o(ans);
en;

return 0;
}

#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
	int n, k;
	cin >> n >> k;
	k = abs(k);
	vector<ll> v(2 * n + 1);
	for (int i = 2; i <= 2 * n; i++) {
		v[i] = min(i - 1, 2 * n - i + 1);
	}
	ll ans = 0;
	for (int i = k + 1; i <= 2 * n; i++) {
		ans += v[i] * v[i - k];
	}
	cout << ans << endl;
	return 0;
}