#include <bits/stdc++.h>
using namespace std;
const int INF = int(1e9);
const double EPS = 1e-8;
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
int main() {
  std::ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  k = min(k, n / 2);
  long long res = 0;
  for (int i = 0; i < k; i++) {
    res += 2 * (n - 1) - 1;
    n -= 2;
  }
  cout << res << endl;
  return 0;
}
