#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>

/*
#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

struct Point {
	int x;
	int w;
};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n; cin >> n;

	vector<Point> points(n);
	FOR_LT(i, 0, n) {
		cin >> points[i].x >> points[i].w;
	}
	sort(points.begin(), points.end(), [](const auto& l, const auto& r) {
		return l.x < r.x;
	});

	multimap<int, int> trans;
	FOR_LT(i, 0, n + 1) {
		{
			int d = points[i + 1].x - points[i].x;
			int w = points[i + 1].w + points[i].w;
			if (w <= d) {
				trans.insert(make_pair(i, i + 1));
				continue;
			}
		}

		// not adjusent case
		FOR_LT(j, i + 2, n + 2) {
			int d = points[j].x - points[i].x;
			int w = points[j].w + points[i].w;
			if (w <= d) {
				trans.insert(make_pair(i, j));
				break;
			}
		}
		FOR_DW(j, i - 1, 0) {
			int d = points[i + 1].x - points[j].x;
			int w = points[i + 1].w + points[j].w;
			if (w <= d) {
				trans.insert(make_pair(j, i + 1));
				break;
			}
		}
	}

	vector<int> score(n + 2, 0);
	score[0] = 1;
	for (auto& elem : trans) {
		int next_score = score[elem.first] + 1;
		if (score[elem.second] < next_score) {
			score[elem.second] = next_score;
		}
	}

	cout << score[n + 1] - 2 << endl;

	return 0;
}

*/

/*
#define REP(a,b) for(int a=0; a<(b); ++a)
#define FWD(a,b,c) for(int a=(b); a<(c); ++a)
#define FWDS(a,b,c,d) for(int a=(b); a<(c); a+=d)
#define BCK(a,b,c) for(int a=(b); a>(c); --a)
#define ALL(a) (a).begin(), (a).end()
#define SIZE(a) ((int)(a).size())
#define VAR(x) #x ": " << x << " "
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll
#define gcd __gcd
#define x first
#define y second
#define st first
#define nd second
#define pb push_back

using namespace std;

template<typename T> ostream& operator<<(ostream &out, const vector<T> &v){ out << "{"; for(const T &a : v) out << a << ", "; out << "}"; return out; }
template<typename S, typename T> ostream& operator<<(ostream &out, const pair<S,T> &p){ out << "(" << p.st << ", " << p.nd << ")"; return out; }

typedef long long LL;
typedef pair<int, int> PII;
typedef long double K;
typedef vector<int> VI;

const int INF = 1000000000;

const int dx[] = {0,0,-1,1}; //1,1,-1,1};
const int dy[] = {-1,1,0,0}; //1,-1,1,-1};

int n, res;
int X[200010];
int W[200010];
int R[200010];

struct event {
	int i, type, x;
};

bool cmp(event a, event b){
	if(a.x != b.x) return a.x < b.x;
	return a.type < b.type;
}

vector<event> E;

int main(){
	cin >> n;
	event e;
	FWD(i,0,n){
		cin >> X[i] >> W[i];
		e.i = i;
		e.type = 1;
		e.x = X[i] - W[i];
		E.push_back(e);
		e.type = -1;
		e.x = X[i] + W[i];
		E.push_back(e);
	}
	sort(ALL(E), cmp);
	FWD(i,0,SIZE(E)){
		e = E[i];
		printf("event %d %d %d\n", e.type, e.i , e.x);
		if(e.type == -1) res = max(res, R[e.i]);
		else R[e.i] = res + 1;

		printf("res : %d\n", res);
	}
	printf("%d\n", res);
	return 0;
}
*/

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int64_t n, m; cin >> n >> m;

	int64_t ans = 0;
	ans += (n / m) * (n / m) * (n / m);
	if ((m & 1) == 0) {
		int64_t d = (n / (m / 2)) - n / m;
		ans += d * d * d;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256