#include <bits/stdc++.h>
using namespace std;

string s;
int K;
long long dp[20][2][20][11][2][2];
bool vis[20][2][20][11][2][2];

long long dfs(int pos, int tight, int cnt, int last, int found, int started) {
    if (pos == (int)s.size())
        return found;

    long long &res = dp[pos][tight][cnt][last][found][started];
    if (vis[pos][tight][cnt][last][found][started]) return res;
    vis[pos][tight][cnt][last][found][started] = true;
    res = 0;

    int limit = tight ? (s[pos] - '0') : 9;

    for (int d = 0; d <= limit; d++) {
        int ntight = tight && (d == limit);
        int nstarted = started || (d != 0);
        int ncnt = cnt, nfound = found;

        if (!nstarted) {
            ncnt = 0;
        } else {
            if (started && d == last) ncnt = cnt + 1;
            else ncnt = 1;
            if (ncnt >= K) nfound = 1;
        }

        res += dfs(pos + 1, ntight, ncnt, nstarted ? d : 10, nfound, nstarted);
    }
    return res;
}

long long solve(long long n) {
    if (n < 0) return 0;
    s = to_string(n);
    memset(vis, 0, sizeof(vis));
    return dfs(0, 1, 0, 10, 0, 0);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long long A, B;
    cin >> A >> B >> K;
    cout << solve(B) - solve(A - 1);
    return 0;
}
