import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines mod = 10**9 + 7 def solve(x, mode): size = len(x) dpy = [0] * 24 dpn = [0] * 24 nowisy = 0 now24 = 0 for num in range(size): ndpy = [0] * 24 ndpn = [0] * 24 #継続 for i in range(10): if i == 3: for j in range(24): ndpy[(i+10*j)%24] += dpy[j] + dpn[j] ndpy[(i+10*j)%24] %= mod else: for j in range(24): ndpy[(i+10*j)%24] += dpy[j] ndpy[(i+10*j)%24] %= mod ndpn[(i+10*j)%24] += dpn[j] ndpn[(i+10*j)%24] %= mod #新規 if num > 0: for i in range(1, 10): if i == 3: ndpy[i] += 1 else: ndpn[i] += 1 targ = int(x[num]) now24 = now24 * 10 % 24 #解放 if nowisy: for i in range(num<1, targ): ndpy[(i+now24)%24] += 1 else: for i in range(num<1, targ): if i == 3: ndpy[(i+now24)%24] += 1 else: ndpn[(i+now24)%24] += 1 for i in range(24): dpn[i] = ndpn[i] dpy[i] = ndpy[i] if targ == 3: nowisy = 1 now24 = (now24+targ) %24 if mode: if nowisy: dpy[now24] += 1 else: dpn[now24] += 1 ans = 0 for i in range(24): if i % 8 != 0: ans += dpy[i] ans %= mod if i % 3 == 0: ans += dpn[i] ans %= mod return ans a,b = input().split() print((solve(b, 1)-solve(a, 0)) % mod)