import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(int n, int k) {
    long[int] d;
    for (int i = 1; i <= n; i++) {
        d[i % k]++;
    }

    long ans = 0;
    for (int i = 1; i <= n; i++) {
        int a = i % k;
        int bc = (k - a) % k;
        if ((bc + bc) % k != 0) continue;

        ans += d[bc] ^^ 2;
    }
    return ans;
}

void main() {
    auto nk = readints;
    int n = nk[0], k = nk[1];
    writeln(calc(n, k));
}
