#include <bits/stdc++.h>
using namespace std;
long long n;
long long arr[1666666];
signed main() {
  long long n, x;
  cin >> n >> x;
  long long ans = 0;
  ans = n - x;
  for (long long i = x; i >= 1; i--) ans += 3 * i;
  cout << ans;
  return 0;
}
