import java.io.*;
import java.util.*;

public class exchange_as implements Runnable {

    long[] u;
    long[][][] v;

    public long count(long x) {
        if (x == 0) {
            return 0;
        }
        
        int[] d = new int[20];
        for (int i = 0; i < 20; i++) {
            d[i] = (int) (x % 10);
            x = x / 10;
        }

        int p = 19;
        while (d[p] == 0) {
            p--;
        }

        long a = 0;
        for (int i = 0; i < p; i++) {
            a += u[i + 1];
        }

        int[] o = new int[10];
        int on = 0;
        int tw = 10;
        for (int i = p; i >= 0; i--) {
            int f = 1;
            if (i < p) {
                f = 0;
            }

            for (int j = f; j < d[i]; j++) {
                if (o[j] == 2) {
                    continue;
                }
                o[j]++;
                if (o[j] == 1) {
                    tw--;
                    on++;
                } else {
                    on--;
                }
                a += v[i][on][tw];
                o[j]--;
                if (o[j] == 0) {
                    tw++;
                    on--;
                } else {
                    on++;
                }
            }

            o[d[i]]++;
            if (o[d[i]] > 2) {
                return a;
            }
            if (o[d[i]] == 1) {
                tw--;
                on++;
            } else {
                on--;
            }
        }
        a++;

        return a;
    }

    public long countDumb(long x) {
        long a = 0;

        for (long y = 1; y <= x; y++) {
            int[] d = new int[20];
            long z = y;
            for (int i = 0; i < 20; i++) {
                d[i] = (int) (z % 10);
                z = z / 10;
            }
            int p = 19;
            while (d[p] == 0) {
                p--;
            }

            int[] o = new int[10];
            boolean ok = true;
            for (int i = 0; i <= p; i++) {
                o[d[i]]++;
                if (o[d[i]] > 2) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                a++;
            }
        }

        return a;
    }

    public void solve() throws IOException {
        Scanner in = new Scanner(new File("exchange.in"));
        PrintWriter out = new PrintWriter(new File("exchange.out"));

        v = new long[20][11][11];
        for (int j = 0; j <= 10; j++) {
            for (int k = 0; j + k <= 10; k++) {
                v[0][j][k] = 1;
            }
        }
        for (int i = 1; i < 20; i++) {
            for (int j = 0; j <= 10; j++) {
                for (int k = 0; j + k <= 10; k++) {
                    if (j > 0) {
                        v[i][j][k] += j * v[i - 1][j - 1][k];
                    }
                    if (k > 0) {
                        v[i][j][k] += k * v[i - 1][j + 1][k - 1]; 
                    }
                }
            }
        }
        u = new long[20];
        for (int i = 1; i < 20; i++) {
            u[i] = v[i][0][10] - v[i - 1][1][9];
        }

        long l = in.nextLong();
        long r = in.nextLong();
        long a = count(r) - count(l - 1);
        out.println(a);

        in.close();
        out.close();
    }

    public void run() {
        try {
            solve();
        } catch (IOException e) {
            System.exit(64);
        }
    }

    public static void main(String[] arg) throws IOException {
        new Thread(new exchange_as()).start();
    }
}
