#include <bits/stdc++.h>
using namespace std;
int finda(long long n, long long z, long long b, int Min, int Max) {
  while (Max - Min > 1) {
    int Mid = (Max + Min) / 2;
    long long t = b * (n - z + b) - Mid * (2 * n - 2 * Mid + z);
    if (t < 0)
      Max = Mid;
    else
      Min = Mid;
  }
  return Max;
}
int findz(long long n, long long z, long long b, int Min, int Max) {
  while (Max - Min > 1) {
    int Mid = (Max + Min) / 2;
    long long t = b * (n - z + b) - Mid * (2 * n - 2 * Mid + z);
    if (t < 0)
      Min = Mid;
    else
      Max = Mid;
  }
  return Min;
}
int findb(long long n, long long x, long long a, int Min, int Max) {
  while (Max - Min > 1) {
    int Mid = (Max + Min) / 2;
    long long t = -n * n + n * (a + Mid) + 2 * a * Mid + x * x + x * (Mid - a);
    if (t < 0)
      Min = Mid;
    else
      Max = Mid;
  }
  return Min;
}
long long f(long long n, long long x, long long a, long long b) {
  return -n * n + n * (a + b) + 2 * a * b + x * x + x * (b - a);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int i, j;
  int from = m + 1;
  int to = n - m;
  long long res = 0;
  long long cnt = 0;
  for (i = (from); i < (to + 1); ++i) {
    int x = n + 1 - i - i;
    if (x < 0) break;
    int a = from;
    int b = findb(n + 1, x, a, from - 1, to + 1);
    int value = f(n + 1, x, a, b);
    int aa = n + 1 + a + a + x;
    int bb = n + 1 - x + 2 * (from - 1);
    int r = 0;
    b -= from - 1;
    for (j = from; j <= to && b > 0; ++j) {
      r += b;
      value += bb + b + b;
      aa += 2;
      while (value >= 0) {
        value -= aa;
        --b;
      }
    }
    long long c = x == 0 ? 1 : 2;
    res += c * r;
  }
  printf("%lld\n", 3 * res);
  return 0;
};
