# include # include #include # include #include #include #include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include #include #include #include #include #include //#include using namespace std; using LL = long long; using ULL = unsigned long long; long long MOD = 1000000000+7; constexpr long long INF = numeric_limits::max(); const double PI = acos(-1); #define fir first #define sec second #define thi third #define debug(x) cerr<<#x<<": "< Pll; typedef pair> Ppll; typedef pair>> Pbll; typedef pair>> Pvll; typedef pair Vec2; struct Tll { LL first, second, third; }; typedef pair Ptll; #define rep(i,rept) for(LL i=0;i=0;i--) LL h, w, n, m, k, t, s, q, last, cnt, sum[2000000], ans, d[200000], a[2000000], b[2000000],rnd[200000]; string str[2],ss; bool f; char c; int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } }; struct Edge { LL to, cost; }; vectorvec[100000],hashs[100000]; vectorv; mapma; setst; void YN(bool f) { if (f) cout << "YES" << endl; else cout << "NO" << endl; } void yn(bool f) { if (f) cout << "Yes" << endl; else cout << "No" << endl; } LL dp[20000][2][2][3][8]; LL func(string x) { rep(i, x.size()+1)rep(j, 2)rep(n, 2)rep(k, 3)rep(l, 8) { dp[i][j][n][k][l] = 0; } dp[0][0][0][0][0] = 1; rep(i, x.size()) { rep(j, 2) { int lim = (j == 1 ? 9 : x[i] - '0'); rep(m, 2) rep(l, 3) { rep(n, 8) {rep(k, lim + 1) { dp[i + 1][j || k < lim][m || k == 3][(l + k) % 3][(n + d[x.size() - i - 1] * k) % 8] += dp[i][j][m][l][n]; dp[i + 1][j || k < lim][m || k == 3][(l + k) % 3][(n + d[x.size() - i - 1] * k) % 8] %= MOD; } } } } } ans = 0; rep(i, 2)rep(j, 3)rep(k, 8)rep(l, 2) { if ((j == 0 || l == 1) && k != 0) ans += dp[x.size()][i][l][j][k]; ans %= MOD; } return ans; } int main() { cin >> str[0] >> str[1]; d[0] = 1; rep(i, str[1].size()) { d[i + 1] = (d[i] * 10) % 8; } rep(i, str[0].size()) { if (str[0][str[0].size() - 1 - i]=='0') { str[0][str[0].size() - 1 - i] += 9; } else { str[0][str[0].size() - 1 - i]--; break; } } cout << func(str[1]) - func(str[0]) << endl; return 0; }