#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  long long a,b;
  cin>>a>>b;
  if(b==1) cout<<a*(a-1)/2<<endl;
  else cout<<(a-b+3)*(a-b)/2+b-2<<endl;
  
  return 0;
}

