#include <iostream>
//#include <fstream>
#include <string>
#include <algorithm>

using namespace std;

//ifstream cin ("x.in");
//ofstream cout ("x.out");

const int nmax = 100;
int lim;
int cif[ 20 ];

long long solve (long long x) {
    long long e, str;
    e = 1;
    str = 0;

    int nrc = 0;
    do {
        cif[ ++ nrc ] = x % 10;
        x /= 10;
    } while (x > 0);

    long long aux = 1;
    for (int i = 1; i < nrc; ++ i) {
        aux *= (10 - lim);
        str += aux;
    }

    for (int i = nrc; i > 0; -- i) {
        if (cif[ i ] < lim) {
            e = 0;
        }

        aux = 1;
        for (int j = i - 1; j > 0; -- j) aux *= (10 - lim);

        str += e * (cif[ i ] - lim) * aux;
    }
    str += e;
    return str;
}

int main() {
    long long a, b;
    cin >> a >> b;

    if (a > 9) {
        cout << "0"; return 0;
    }

    lim = a;

    cout << solve(b - 1) - solve(a - 1) << "\n";
    return 0;
}