#include<bits/stdc++.h>
using namespace std;

using ll=long long;
int main(){
    ll n,d;
    cin>>n>>d;
    if(d!=1) cout<<(n-d+2)*(n-d+1)/2+d-3<<endl;
    else cout<<n*(n-1)/2<<endl;
    return 0;
}
