#include <iostream>
using namespace std;

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

    return 0;
}