#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;
}

