#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    ll N, D;
    cin >> N >> D;
    if(D == 1) {
        cout << N * (N - 1) / 2 << endl;
    }
    else if(D == 2){
        cout << N * (N - 1) / 2 - 1 << endl;
    }
    else{
        ll A = N - (D - 2);
        cout << A * (A - 1) / 2 - 1 + D - 2 << endl;
    }
    
    
    return 0;
}
### Prompt

In Cpp, your task is to solve the following problem:

Problem

There are n vertices that are not connected to any of the vertices.
An undirected side is stretched between each vertex.
Find out how many sides can be stretched when the diameter is set to d.
The diameter represents the largest of the shortest distances between two vertices.
Here, the shortest distance is the minimum value of the number of sides required to move between vertices.
Multiple edges and self-loops are not allowed.

Constraints

* 2 ≤ n ≤ 109
* 1 ≤ d ≤ n−1

Input


n d


Two integers n and d are given on one line, separated by blanks.

Output

Output the maximum number of sides that can be stretched on one line.

Examples

Input

4 3


Output

3


Input

5 1


Output

10


Input

4 2


Output

5

### Response

```cpp
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    ll N, D;
    cin >> N >> D;
    if(D == 1) {
        cout << N * (N - 1) / 2 << endl;
    }
    else if(D == 2){
        cout << N * (N - 1) / 2 - 1 << endl;
    }
    else{
        ll A = N - (D - 2);
        cout << A * (A - 1) / 2 - 1 + D - 2 << endl;
    }
    
    
    return 0;
}
```