#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
using namespace std;
template<class T> bool max_self(T & a, const T & b){
return b > a ? a = b, true : false;
}
template<class T> bool min_self(T & a, const T & b){
return b < a ? a = b, true : false;
}
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);
const int nax = 1e5 + 5;
int f, t, x, dp[nax][2];
string from, to;
int util(string a){
int N = SZ(a);
memset(dp, 0, sizeof dp);
for(int idx = N - 1, lim; idx >= 0; --idx){
lim = a[idx] - '0';
for(int d = 0; d <= 9; ++d){
dp[idx][0] += dp[idx + 1][0];
if(d == x) dp[idx][0] += pow(10, N - 1 - idx);
}
for(int d = 0; d <= lim; ++d){
dp[idx][1] += dp[idx + 1][d == lim];
if(d == x){
string rest = a.substr(idx + 1);
if(d == lim && idx < N - 1) dp[idx][1] += stoi(rest) + 1;
else dp[idx][1] += pow(10, N - 1 - idx);
}
}
}
return dp[0][1];
}
int main(){
FAST_IO
cin >> f >> t >> x;
from = to_string(f - 1), to = to_string(t);
cout << util(to) - util(from);
return 0;
}
I2luY2x1ZGUgImJpdHMvc3RkYysrLmgiCiNkZWZpbmUgUFJFQ0lTSU9OKHgpIGNvdXQgPDwgZml4ZWQgPDwgc2V0cHJlY2lzaW9uKHgpCiNkZWZpbmUgRkFTVF9JTyBpb3M6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7IGNpbi50aWUoTlVMTCk7IGNvdXQudGllKE5VTEwpOwojZGVmaW5lIFNaKFgpICgoaW50KShYKS5zaXplKCkpCiNkZWZpbmUgQUxMKFgpIChYKS5iZWdpbigpLCAoWCkuZW5kKCkKI2RlZmluZSBBTExSKFgpIChYKS5yYm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