import bisect import copy import decimal import fractions import heapq import itertools import math import random import sys import time from collections import Counter,deque,defaultdict from functools import lru_cache,reduce from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max def _heappush_max(heap,item): heap.append(item) heapq._siftdown_max(heap, 0, len(heap)-1) def _heappushpop_max(heap, item): if heap and item < heap[0]: item, heap[0] = heap[0], item heapq._siftup_max(heap, 0) return item from math import gcd as GCD read=sys.stdin.read readline=sys.stdin.readline readlines=sys.stdin.readlines write=sys.stdout.write A,B=readline().split() A=list(map(int,list(A))) B=list(map(int,list(B))) mod=10**9+7 def solve(N): dp0=[0]*24 dp1=[0]*24 for i in range(1,N[0]): if i==3: dp1[i]+=1 else: dp0[i]+=1 s=N[0] bl=(N[0]==3) for n in N[1:]: prev0=dp0 prev1=dp1 dp0=[0]*24 dp1=[0]*24 for p in range(24): for i in range(10): if i==3: dp1[(p*10+i)%24]+=prev0[p] dp1[(p*10+i)%24]+=prev1[p] dp1[(p*10+i)%24]%=mod else: dp0[(p*10+i)%24]+=prev0[p] dp1[(p*10+i)%24]+=prev1[p] dp0[(p*10+i)%24]%=mod dp1[(p*10+i)%24]%=mod for i in range(n): if bl|(i==3): dp1[(s*10+i)%24]+=1 else: dp0[(s*10+i)%24]+=1 for i in range(1,10): if i==3: dp1[i]+=1 else: dp0[i]+=1 s=(s*10+n)%24 bl|=n==3 return (sum(dp0[3::3])+sum(dp1)-sum(dp1[::8]))%mod ans=(solve(B)-solve(A))%mod B+=[0]*2 if 3 in B and sum(B)%3==0 and (B[2]*100+B[1]*10+B[0])%8==0: ans+=1 ans%=mod print(ans)