{双亲数
数值递推
Author: yangbohua
Time: 2011-04-12}
program parents;
var
f:array[0..1000000] of int64;
i,j,x,d:longint;
a,b,c,last,i1:int64;
begin
assign(input,'parents.in');
reset(input);
assign(output,'parents.out');
rewrite(output);
readln(a,b,x);
last:=-1;
if a<b then c:=a else c:=b;
i:=(c div x)*x;
while i>=x do
begin
i1:=i;
f[i]:=(a div i1)*(b div i1);
if f[i]=last then
f[i]:=f[i+x]
else
begin
last:=f[i];
d:=c div i;
for j:=2 to d do
f[i]:=f[i]-f[i*j];
end;
i:=i-x;
end;
writeln(f[x]);
close(input);
close(output);
end.