#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
using ll = long long;
#define rep(j,k) for (int j = 0; j < (int)(k); j++)


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    ll n, d;
    while (cin >> n >> d) {
        ll x = d - 1;
        ll y = n - x;
        ll ans = y*(y - 1) / 2 + max(0LL, x - 1) + (x >= 1 ? max(0LL, y - 1) : 0);
        cout << ans << endl;
    }
}