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

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
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) {
    auto m = new int[k];
    for (int i = 1; i <= n; i++)
        m[i % k]++;

    long ans = 0;
    for (int i = 1; i <= n; i++) { // a を固定
        int a = i % k;
        int b = (k - a) % k;
        int c = (k - a) % k;
        if ((b + c) % k == 0) {
            ans += m[b] * m[c];
        }
    }
    return ans;
}

void main() {
    int n, k; scan(n, k);
    writeln(calc(n, k));
}
