#include <bits/stdc++.h>
int main() {
  long long n, k;
  std::cin >> n >> k;
  std::cout << n * (n * n - 1) / 6 + n - k * (k - 1) * n / 2 + k - 1 -
                   k * (k - 1) * (2 * k - 1) / 6;
}
