#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e12;
const int MAXN = 1e5 + 1, MODM = 1e9 + 7, P = 1e6 + 3, MULT1 = 30, MULT2 = 239,
          LUCKY = 13, ELEVEN = 11, MAXM = 101, k = 200;
int main() {
  ios_base::sync_with_stdio(0);
  long long n, k;
  cin >> n >> k;
  long long ans = 0;
  long long c = 1;
  for (int i = 0; i < k; i++) {
    ans += max(n - c, 0LL);
    ans += max(n - c - 1, 0LL);
    c += 2;
  }
  cout << ans;
  return 0;
}
