#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <cassert>
#include <numeric>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int64_t mod = 1000000007;
const int64_t tmpMod = 998244353;

int64_t getNum(int64_t N, int64_t n) {
  return N-abs(n-N) > 0 ? N-abs(n-N): 0;
}

int main() {
 
  int64_t N,K,ans=0;
  cin>>N>>K;

  // unordered_map<int, int> map;

  //vector<int64_t> A(N);
  for(int64_t i=1; i<=2*N-K-1; i++){
    // cout<<i << " " <<getNum(N,i)<<" "<<getNum(N,i+K)<<endl;
    ans+=(getNum(N,i) * getNum(N,i+K));
  }
  //vector<vector<int> > A(N,vector<int>(M));
  // for(int i=1; i<=N; i++){
  //   for(int j=1; j<=N; j++){
  //       map[i+j]++;
  //   }
  // }
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  cout << ans << endl;
}

#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; ++i)
const ll INF = 1LL << 60;
const double EPS = 1e-20;
const ll MOD = 1000000007;
const double pi = 3.141592653589793;

/*  //1
int main() {
    ll n;
    cin >> n;
    cout << (n+1)*5000 << endl;
}
//*/

//*  //2
ll _4Hr(ll r){
    return double(3+r)/6*(2+r)*(1+r);
}
int main() {
    ll n, k;
    cin >> n >> k;
    ll J = 2*n - 2 - abs(k);
    ll ans = _4Hr(J);
    if (J > n - 1) ans -= 4 * _4Hr(J - n);
    cout << ans << endl;
    // k = abs(k);
    // FOR(i, 2, 2*n-k+1) {
    //     ll x1=min((k+i)-1, 2*n+1-(k+i));
    //     ll x2=min(i-1, 2*n+1-i);
    //     ans += x1 * x2;
    // }
}
//*/

/*  //3
//https://atcoder.jp/contests/code-festival-2015-morning-middle/tasks/cf_2015_morning_easy_c
int main() {
    ll n, k, m, r;
    cin >> n >> k >> m >> r;
    vll s(n-1);
    rep(i, n-1) cin >> s[i];
    sort(s.begin(), s.end(), greater<ll>());

    long double sum = 0;
    rep(i, k) sum += (long double)(s[i]) / k;
    // if (sum >= r * k) {
    //     cout << 0 << endl;
    // } else {
    //     ll score = r * k - (sum - s[k - 1]);
    //     cout << ((score > m) ? -1 : score) << endl;
    // }
    if (sum >= r) {
        cout << 0 << endl;
    } else {
        ll score = ((long double)r - (sum - (long double)(s[k - 1]) / k)) * k;
        cout << ((score > m) ? -1 : score) << endl;
    }
}
//*/

/*  //4
// https://atcoder.jp/contests/arc118/tasks/arc118_c
int main() {
    ll n;
    cin >> n;
    vll v;
    if (n == 3) {
        v.push_back(6);
        v.push_back(10);
        v.push_back(15);
    } else if (n == 4) {
        v.push_back(210 / 2);
        v.push_back(210 / 3);
        v.push_back(210 / 5);
        v.push_back(210 / 7);
    } else {
        ll q[] = {2, 3, 5, 7, 11};
        rep(z, 4) {
            rep(i, 30) {
                rep(J, 20) {
                    rep(k, 20) {
                        rep(L, 10) {
                            ll p = pow(q[(z > 0)], i);
                            if (p > 10000) break;
                            ll tmp = pow(q[1 + (z > 1)], J);
                            if (tmp > 10000) break;
                            p *= tmp;
                            tmp = pow(q[2 + (z > 2)], k);
                            if (tmp > 10000) break;
                            p *= tmp;
                            tmp = pow(q[3 + (z > 3)], L);
                            if (tmp > 10000) break;
                            p *= tmp;
                            v.push_back(p);
                        }
                    }
                }
            }
        }
    }
    rep(i, n) cout << v[i] << " ";
    cout << endl;
    cout << v.size() << endl;
}
//*/
