#include<fstream>
using namespace std;
int main()
{
    ifstream in("aparitii.in");
    ofstream out("aparitii.out");
	long long a,b,p=1,aux,c,s2=0,s1=0;
    in>>a>>b>>c;
    aux=b;
    while(aux>0)
    {
        if(aux%10>c)
            s2=s2+p+(b/(p*10))*p;
        else
            if(aux%10==c)
            	s2=s2+1+b%p+(b/(p*10))*p;
            else
            	s2=s2+(b/(p*10))*p;
         aux/=10;
        p*=10;
    }
   //out<<s2<<endl;;
    aux=a;
    p=1;
    while(aux>0)
    {
        if(aux%10>c)
            s1=s1+p+(a/(p*10))*p;
        else
            if(aux%10==c)
            	s1=s1+1+a%p+(a/(p*10))*p;
            else
            	s1=s1+(a/(p*10))*p;
         aux/=10;
        p*=10;
    }
   //out<<s1<<endl;;
    out<<s2-s1<<endl;;
}
