var
	a, b, k, ans, i : longint;
function check(x  :longint) : boolean;
var
	last, tek, len : longint;
begin
	check := false;
	if (k = 1) then
	begin
		check := true;
		exit;
	end;
	tek := x mod 10;
	len := 1;
	x := x div 10;
	while (x > 0) do
	begin
		last := tek;
		tek := x mod 10;
		if (last = tek) then len := len + 1
				else len := 1;
		if (len = k) then check := true;
		x := x div 10;
	end;
end;
begin
	reset(input, 'interesting.in');
	rewrite(output, 'interesting.out');
	readln(a, b, k);
	ans := 0;
	for i := a to b do
		if check(i) then inc(ans);
	writeln(ans);
end.