program n_1;
var
n, m, k, b, c, d:integer;
begin
read(n,m,k);
if k<3 then writeln('0') else begin</p>
c:= m div 2;
b:= n mod (k-2);
d:= n div (k-2);
if (b<>0) then d:=d+1;
if (d>c) then writeln('0')
else if (n+m) mod k = 0 then writeln((n+m) div k)
else writeln((n+m) div k + 1);
end;
end.