{$R+,Q+}
var
	a, b: int64;
	q, kol, i, j, k, lengthN : longint;
	d : array[0..20, 0..20, 0..10, false..true] of int64;
	step : array[0..20] of int64;
	predb : array[0..20] of longint;
function leng(a : int64) : longint;
var
	tmp : longint;
begin	
	tmp := 0;
	while (a > 0) do
	begin
		a := a div 10;
		inc(tmp);
	end;
	leng := tmp;
end;

function atB(i : longint) : longint;
var
	q : longint;
begin
	atB := predb[i];
end;

procedure pre(N : int64);
var
	q : int64;
  i : longint;
begin
	q := N;
	for i := lengthN downto 1 do
	begin	
		predb[i] := q mod 10;
		q := q div 10;
	end;
end;

function chislo (n : int64; i : longint) : int64;
begin
	chislo := n mod step[i];
end;

procedure nulld; 
begin     	
	for i := 0 to 20 do
		for kol := 0  to 20 do
			for j := 0 to 10 do
			begin 	
				d[i][kol][j][false] := 0;
				d[i][kol][j][true] := 0;
			end;
end;

function gen_answer(N : int64) : int64;
var
	ans_for_N : int64;
begin
	nulld;
	lengthN := leng(N);
	pre(N);	
	for j := 1 to atB(1) - 1 do
		d[1][1][j][false] := 1;
	d[1][1][atB(1)][true] := 1;

	for i := 2 to lengthN do
	begin
		for j := 0 to 9 do      //Хотим поставить j
		begin
			if (j < atB(i)) then
			begin
				for q := 0 to 9 do //Последний символ был q
				begin
					if (i = 2) and (q = 0) then continue;
					if (q = j) then
						for kol := 2 to 19 do
							d[i][kol][q][false] := d[i][kol][q][false] + d[i - 1][kol - 1][q][false] + d[i - 1][kol - 1][q][true];
					if (q <> j) then
						for kol := 1 to k - 1 do
							d[i][1][j][false] := d[i][1][j][false] + d[i - 1][kol][q][false] + d[i - 1][kol][q][true];
				end;
			end;
			if (j = atB(i)) then
			begin	
				for q := 0 to 9 do 
				begin
					if (i = 2) and (q = 0) then continue;
					if (q = j) then 
						for kol := 2 to 19 do                                                                               
						begin
							d[i][kol][q][false] := d[i][kol][q][false] + d[i - 1][kol - 1][q][false];
							d[i][kol][q][true] := d[i][kol][q][true] + d[i - 1][kol - 1][q][true];
						end;
					if (q <> j) then                                        
						for kol := 1 to k - 1 do
						begin
							d[i][1][j][false] := d[i][1][j][false] + d[i - 1][kol][q][false];
							d[i][1][j][true] := d[i][1][j][true] + d[i - 1][kol][q][true];
						end;
				end;
			end;
			if (j > atB(i)) then
			begin
				for q := 0 to 9 do //Последний символ был q
				begin
					if (i = 2) and (q = 0) then continue;
          				if (q = j) then
						for kol := 2 to 19 do
							d[i][kol][q][false] := d[i][kol][q][false] + d[i - 1][kol - 1][q][false];
					if (q <> j) then                                        
						for kol := 1 to k - 1 do
							d[i][1][j][false] := d[i][1][j][false] + d[i - 1][kol][q][false];
				end;
			end;
		end;
	end;
        
	ans_for_N := 0;
	for i := 1 to lengthN do
	begin
		for j := 0 to 9 do
			ans_for_N := ans_for_N + d[i][k][j][false] * step[lengthN - i];	
		for j := 0 to 9 do
			ans_for_N := ans_for_N + d[i][k][j][true] * (chislo(N, lengthN - i) + 1);
	end;
	gen_answer := ans_for_N;
end;

function ans(x : int64) : int64;
var
	q : longint;
	tek : int64;
begin
	q := 1;   
	tek := 0;
	while x >= step[q] do
	begin              
		tek := tek + gen_answer(step[q] - 1);
		inc(q);
	end;
	ans := tek + gen_answer(x); 
end;

begin
	reset(input, 'interesting.in');
	rewrite(output, 'interesting.out');
	readln(a, b, k);
	step[0] := 1;
	for i := 1 to 18 do
		step[i] := step[i - 1] * 10;
	step[19] := 4 * step[18] + 1;
	writeln(ans(b) - ans(a - 1));	
end.