import static java.
lang.
Math.
*; import static java.
util.
Arrays.
*;
public class FoxMakingDiceEasy {
int N, K;
public int theCount(int N, int K) {
this.N = N;
this.K = K - 2;
int ret = 0;
for (int i = 0; i < N; i++)
for (int j = i + 1; j < N; j++)
for (int k = j + 1; k < N; k++)
ret += count(i, j, k);
return ret * 2;
}
int count(int i, int j, int k) {
int ret = 0;
loop: for (int s = max(K, k * 2 + 1); s < 2 * N; s++) {
int[] is = { i, j, k, s - i, s - j, s - k };
sort(is);
if (is[5] >= N)
break;
for (int n = 0; n < 5; n++)
if (is[n] == is[n + 1])
continue loop;
ret++;
}
return ret;
}
}
aW1wb3J0IHN0YXRpYyBqYXZhLmxhbmcuTWF0aC4qOwppbXBvcnQgc3RhdGljIGphdmEudXRpbC5BcnJheXMuKjsKCnB1YmxpYyBjbGFzcyBGb3hNYWtpbmdEaWNlRWFzeSB7CgogICAgaW50IE4sIEs7CgogICAgcHVibGljIGludCB0aGVDb3VudChpbnQgTiwgaW50IEspIHsKICAgICAgICB0aGlzLk4gPSBOOwogICAgICAgIHRoaXMuSyA9IEsgLSAyOwogICAgICAgIGludCByZXQgPSAwOwogICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgTjsgaSsrKQogICAgICAgICAgICBmb3IgKGludCBqID0gaSArIDE7IGogPCBOOyBqKyspCiAgICAgICAgICAgICAgICBmb3IgKGludCBrID0gaiArIDE7IGsgPCBOOyBrKyspCiAgICAgICAgICAgICAgICAgICAgcmV0ICs9IGNvdW50KGksIGosIGspOwogICAgICAgIHJldHVybiByZXQgKiAyOwogICAgfQoKICAgIGludCBjb3VudChpbnQgaSwgaW50IGosIGludCBrKSB7CiAgICAgICAgaW50IHJldCA9IDA7CiAgICAgICAgbG9vcDogZm9yIChpbnQgcyA9IG1heChLLCBrICogMiArIDEpOyBzIDwgMiAqIE47IHMrKykgewogICAgICAgICAgICBpbnRbXSBpcyA9IHsgaSwgaiwgaywgcyAtIGksIHMgLSBqLCBzIC0gayB9OwogICAgICAgICAgICBzb3J0KGlzKTsKICAgICAgICAgICAgaWYgKGlzWzVdID49IE4pCiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZm9yIChpbnQgbiA9IDA7IG4gPCA1OyBuKyspCiAgICAgICAgICAgICAgICBpZiAoaXNbbl0gPT0gaXNbbiArIDFdKQogICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlIGxvb3A7CiAgICAgICAgICAgIHJldCsrOwogICAgICAgIH0KICAgICAgICByZXR1cm4gcmV0OwogICAgfQp9