#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdio>
using namespace std;
int A,B,i,j,d,ans=0;
int gcd()
{
int a=i,b=j;
if (a<b) swap(a,b);
while (b)
{
a=a%b;
swap(a,b);
}
return a;
}
int main()
{
freopen("parents.in","r",stdin);
freopen("parents.out","w",stdout);
scanf("%d%d%d",&A,&B,&d);
for (i=d;i<=A;i+=d)
for (j=d;j<=B;j+=d)
if (gcd()==d) ++ans;
printf("%d\n",ans);
return 0;
}