#include using namespace std; const int MOD = 1000000007; int dp[10000][2][2][3][8]; int rec(const string& S, int idx, bool free, bool Aho, int three, int eight) { if(idx == S.size()) { return((Aho | (three == 0)) & (eight != 0)); } else if(~dp[idx][free][Aho][three][eight]) { return(dp[idx][free][Aho][three][eight]); } else { int ret = 0; for(int i = max< int >(9 * free, S[idx]); i >= 0; i--) { (ret += rec(S, idx + 1, free|(i != S[idx]), Aho|(i == 3), (three * 10 + i) % 3, (eight * 10 + i) % 8)) %= MOD; } return(dp[idx][free][Aho][three][eight] = ret); } } const int getDP(string S) { for(int i = 0; i < S.size(); i++) S[i] -= '0'; memset(dp, -1, sizeof(dp)); return(rec(S, 0, false, false, 0, 0)); } void Decrement(string& S, int idx) { if(S[idx] == '0') Decrement(S, idx - 1), S[idx] = '9'; else S[idx]--; } int main() { string A, B; cin >> A >> B; Decrement(A, A.size() - 1); cout << (getDP(B) - getDP(A) + MOD) % MOD << endl; }