#include <bits/stdc++.h>
#define int long long
using namespace std;
const int kN = 20;
int f[kN][2][2][2][2][10][10], n, pl;
string l, r;
signed main() {
cin.tie(0)->sync_with_stdio(false);
cin >> l >> r;
n = r.size(), pl = n - l.size();
l = string(pl, '0') + l;
f[0][0][0][0][0][0][0] = 1;
for (int i = 0; i < n; i++) {
for (int x = 0; x < 2; x++) {
for (int y = 0; y < 2; y++) {
for (int s = 0; s < 2; s++) {
for (int c = 0; c < 2; c++) {
for (int q = 1; q <= 9; q++) {
for (int j = 1; j <= 9; j++) {
for (int k = x ? 1 : max(1, l[i] - '0'); k <= (y ? 9 : max(1, r[i] - '0')); k++) {
int nx = x || k > l[i] - '0', ny = y || k < r[i] - '0';
int ns = s || ((q == 4 && j == 8) || (q == 4 && k == 8) || (j == 4 && k == 8) || (q == 8 && j == 4) || (q == 8 && k == 4) || (j == 8 && k == 4));
int nc = c || (q == j && j == k);
f[i + 1][nx][ny][ns][nc][j][k] += f[i][x][y][s][c][q][j] * (!s && c);
}
}
}
}
}
}
}
}
cout << accumulate(f[n][0][0][0][0][0], f[n + 1][0][0][0][0][0], 0ll);
return 0;
}