#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
long long maxx[1000001];
using namespace std;
int main()
{
long long m,n,d;
freopen("parents.in","r",stdin);
freopen("parents.out","w",stdout);
scanf("%lld%lld%lld",&n,&m,&d);
n/=d;m/=d;
for (int i=min(n,m);i>=1;i--)
{
maxx[i]=(n/i)*(m/i);
if ((n/i)!=(n/(i+1))||(m/i)!=(m/(i+1)))
{
for (int j=2;j*i<=min(n,m);j++)
{
maxx[i]-=maxx[i*j];
}
}
else maxx[i]=maxx[i+1];
}
printf("%lld",maxx[1]);
return 0;
}