import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm; import std.uni, std.math, std.container, std.typecons, std.typetuple; import core.bitop, std.datetime; immutable long mod = 10^^9 + 7; void main(){ string a, b; readVars(a, b); long ans = (nabeatsu(b, false) - nabeatsu(a, true) + mod) % mod; writeln(ans); } long nabeatsu(string n, bool miman){ int L = n.length.to!int; auto dp = new long[][][][][](L + 1, 2, 2, 3, 8); dp[0][0][0][0][0] = 1; foreach(i ; 0 .. L){ foreach(j ; 0 .. 2){ foreach(k ; 0 .. 2){ foreach(l ; 0 .. 3){ foreach(m ; 0 .. 8){ for(int d = 0; d <= (j ? 9 : n[i] - '0'); d++){ (dp[i + 1][j || (d < n[i] - '0')][k || (d == 3)][(l + d) % 3][(10*m + d) % 8] += dp[i][j][k][l][m]) %= mod; } } } } } } long ans; if (miman) { foreach(k ; 0 .. 2){ foreach(l ; 0 .. 3){ foreach(m ; 0 .. 8){ if ((k || (l == 0)) && (m != 0)){ (ans += dp[L][1][k][l][m]) %= mod; } } } } } else { foreach(j ; 0 .. 2){ foreach(k ; 0 .. 2){ foreach(l ; 0 .. 3){ foreach(m ; 0 .. 8){ if ((k || (l == 0)) && (m != 0)){ (ans += dp[L][j][k][l][m]) %= mod; } } } } } } return ans; } void readVars(T...)(auto ref T args){ auto line = readln.split; foreach(ref arg ; args){ arg = line.front.to!(typeof(arg)); line.popFront; } if(!line.empty){ throw new Exception("args num < input num"); } }