import sys input = sys.stdin.readline sys.set_int_max_str_digits(10**5) A,B=map(int,input().split()) mod=10**9+7 POW10=[1] for i in range(10**5+2): POW10.append(POW10[-1]*10%24) A-=1 A=list(map(int,str(A))) B=list(map(int,str(B))) def calc(A): DP=[0]*2*2*24 # DP[i][j][k] i=0で一致、i=1で不一致 # j=0で3を含まない。j=1で3を含む # k:24で割った余り DP[0]=1 LEN=len(A) for keta in range(len(A)): x=A[keta] NDP=[0]*2*2*24 for i in range(2): for j in range(2): for k in range(24): now=DP[i+j*2+k*4] if now==0: continue if i==0: for l in range(x+1): if l==3: three=1 else: three=0 plus=l*POW10[LEN-keta-1]%24 if l==x: ic=0 else: ic=1 NDP[ic+(j|three)*2+((k+plus)%24)*4]=(NDP[ic+(j|three)*2+(k+plus)%24*4]+DP[i+j*2+k*4])%mod else: for l in range(10): if l==3: three=1 else: three=0 plus=l*POW10[LEN-keta-1]%24 NDP[i+(j|three)*2+(k+plus)%24*4]=(NDP[i+(j|three)*2+(k+plus)%24*4]+DP[i+j*2+k*4])%mod DP=NDP ANS=0 for i in range(2): for j in range(2): for k in range(24): if j==1 and k%8!=0: ANS+=DP[i+j*2+k*4] else: if k%3==0 and k%8!=0: ANS+=DP[i+j*2+k*4] ANS%=mod return ANS ANS=calc(A) ANS2=calc(B) print((ANS2-ANS)%mod)