#include<iostream>
#include<cstdio>
#include<algorithm>
#define int long long
using namespace std;
int n,k;
int ans=0,poi=0;
signed main(){
scanf("%lld%lld",&n,&k);

for(int i=1;i<=n;i++)ans+=(i%k==0);

if(k%2==0){
    for(int i=1;i<=n;i++)poi+=(i%k==k/2);
}
cout<<ans*ans*ans+poi*poi*poi;
}