#include <bits/stdc++.h>
using namespace std;
const int N = 205;
const int MAX = 2000000000;
const double EPS = 0.000001;
int n, k;
long long ans = (long long)0;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  while (n > 1 && k) {
    ans += (long long)2 * n - (long long)3;
    n -= 2;
    k--;
  }
  cout << ans;
}
