#include using namespace std; using ll = long long; struct node { int k; int ch[10] = {}; }; node nodes[1000000]; int ptr = 2; int create() { return ptr++; } int complement(int x) { if (x == 0) return 1; if (x == 1) return 0; static map memo; if (memo.count(x)) return memo[x]; int res = create(); for (int i = 0; i < 10; i++) { nodes[res].ch[i] = complement(nodes[x].ch[i]); } return memo[x] = res; } int cup(int x, int y) { if (x == 1 || y == 1) return 1; if (x == 0) return y; if (y == 0) return x; static map, int> memo; pair key(x, y); if (memo.count(key)) return memo[key]; int res = create(); for (int i = 0; i < 10; i++) { nodes[res].ch[i] = cup(nodes[x].ch[i], nodes[y].ch[i]); } return memo[key] = res; } int cap(int x, int y) { if (x == 0 || y == 0) return 0; if (x == 1) return y; if (y == 1) return x; static map, int> memo; pair key(x, y); if (memo.count(key)) return memo[key]; int res = create(); for (int i = 0; i < 10; i++) { nodes[res].ch[i] = cap(nodes[x].ch[i], nodes[y].ch[i]); } return memo[key] = res; } constexpr int MOD = 1000000007; class mint { int n; public: mint(int n_ = 0) : n(n_) {} explicit operator int() { return n; } friend mint operator-(mint a) { return -a.n + MOD * (a.n != 0); } friend mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; } friend mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; } friend mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; } friend mint &operator+=(mint &a, mint b) { return a = a + b; } friend mint &operator-=(mint &a, mint b) { return a = a - b; } friend mint &operator*=(mint &a, mint b) { return a = a * b; } friend bool operator==(mint a, mint b) { return a.n == b.n; } friend bool operator!=(mint a, mint b) { return a.n != b.n; } friend istream &operator>>(istream &i, mint &a) { return i >> a.n; } friend ostream &operator<<(ostream &o, mint a) { return o << a.n; } }; mint count(int x) { if (x == 0) return 0; if (x == 1) return 1; static map memo; if (memo.count(x)) return memo[x]; mint res = 0; for (int i = 0; i < 10; i++) { res += count(nodes[x].ch[i]); } return memo[x] = res; } // ------------------------- int LE(string &s, int k = 0, int lt = 0) { if (k == s.size()) return 1; static map, int> memo; tuple key(k, lt); if (memo.count(key)) return memo[key]; int res = create(); for (int i = 0; i < 10; i++) { if (lt == 1 || i <= s[k] - '0') { nodes[res].ch[i] = LE(s, k + 1, lt || (i < s[k] - '0')); } } return memo[key] = res; } int GE(string &s, int k = 0, int gt = 0) { if (k == s.size()) return 1; static map, int> memo; tuple key(k, gt); if (memo.count(key)) return memo[key]; int res = create(); for (int i = 0; i < 10; i++) { if (gt == 1 || i >= s[k] - '0') { nodes[res].ch[i] = GE(s, k + 1, gt || (i > s[k] - '0')); } } return memo[key] = res; } int MULT(int n, int m, int k = 0, int md = 0) { if (k == n) return md == 0; static map, int> memo; tuple key(n, m, k, md); if (memo.count(key)) return memo[key]; int res = create(); for (int i = 0; i < 10; i++) { nodes[res].ch[i] = MULT(n, m, k + 1, (md * 10 + i) % m); } return memo[key] = res; } int HAS(int n, int m, int k = 0) { if (k == n) return 0; static map, int> memo; tuple key(n, m, k); if (memo.count(key)) return memo[key]; int res = create(); for (int i = 0; i < 10; i++) { if (i == m) { nodes[res].ch[i] = 1; } else { nodes[res].ch[i] = HAS(n, m, k + 1); } } return memo[key] = res; } int main() { string A, B; cin >> A >> B; if (A.size() < B.size()) A = string(B.size() - A.size(), '0') + A; int n = A.size(); int le = LE(B); int ge = GE(A); int range = cap(ge, le); int aho = cup(HAS(n, 3), MULT(n, 3)); int seisyun = MULT(n, 8); int ans = cap(range, cap(aho, complement(seisyun))); cout << count(ans) << endl; }