#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T bigmod(T p, T e, T M) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    T t = bigmod(p, e / 2, M);
    return (t * t) % M;
  }
  return (bigmod(p, e - 1, M) * p) % M;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
template <class T>
inline T multimod(T a, T b, T m) {
  T ans = 0ll;
  a %= m, b %= m;
  while (b) {
    if (b & 1ll) ans = m - ans > a ? (ans + a) : (ans + a - m);
    b >>= 1ll;
    a = (m - a) > a ? a + a : a + a - m;
  }
  return (T)ans;
}
const int maxBufSize = (6000000);
struct Input {
  int bufSize, bufEnd, bufPos;
  char buffer[maxBufSize];
  void grabBuffer() {
    bufSize = (maxBufSize);
    bufPos = 0;
    bufEnd = fread(buffer, sizeof(char), bufSize, stdin);
    buffer[bufEnd] = '\0';
  }
  bool bufEof() { return bufPos == bufEnd; }
  int getChar() { return buffer[bufPos++]; }
  void skipWS() {
    while ((buffer[bufPos] == '\n' || buffer[bufPos] == ' ' ||
            buffer[bufPos] == '\t'))
      bufPos++;
  }
  int rInt() {
    int n = 0, x;
    skipWS();
    bool neg = false;
    if ((x = getChar()) == '-') {
      neg = true;
      x = getChar();
    }
    for (; x <= '9' && x >= '0'; x = getChar())
      n = (n << 3) + (n << 1) + (x - '0');
    if (neg)
      return -n;
    else
      return n;
  }
  inline bool isWhiteSpace(char x) {
    return x == ' ' || x == '\n' || x == '\t';
  }
  char rChar() {
    skipWS();
    return getChar();
  }
} input;
long long tmp[(200000 + 7)], d[(200000 + 7)];
long long ans[(200000 + 7)];
int main() {
  int i, j, k;
  int n;
  cin >> n >> k;
  long long ans = 0ll;
  for (i = 1; i <= k && i <= n / 2; i++) {
    ans += (n - i * 2 + 1);
    ans += (n - i * 2);
  }
  cout << ans << endl;
  return 0;
}
