import sys
from collections import defaultdict

MOD = 10**9 + 7

def subtract_one(s):
    s_list = list(s)
    i = len(s_list) - 1
    while i >= 0 and s_list[i] == '0':
        s_list[i] = '9'
        i -= 1
    if i >= 0:
        s_list[i] = str(int(s_list[i]) - 1)
    new_s = ''.join(s_list).lstrip('0')
    return new_s if new_s else '0'

def count(s):
    n = len(s)
    memo = [defaultdict(int) for _ in range(n + 1)]
    memo[0][(True, 0, False, 0, True)] = 1
    
    for i in range(n):
        current_memo = memo[i]
        if not current_memo:
            continue
        next_memo = defaultdict(int)
        for state, cnt in current_memo.items():
            leading_zero_prev, sum_mod3_prev, has_3_prev, mod8_prev, tight_prev = state
            upper_digit = int(s[i]) if tight_prev else 9
            for d in range(0, upper_digit + 1):
                new_tight = tight_prev and (d == upper_digit)
                if leading_zero_prev:
                    if d == 0:
                        new_leading_zero = True
                        new_sum_mod3 = sum_mod3_prev
                        new_has_3 = has_3_prev
                        new_mod8 = mod8_prev
                    else:
                        new_leading_zero = False
                        new_sum_mod3 = d % 3
                        new_has_3 = (d == 3)
                        new_mod8 = d % 8
                else:
                    new_leading_zero = False
                    new_sum_mod3 = (sum_mod3_prev + d) % 3
                    new_has_3 = has_3_prev or (d == 3)
                    new_mod8 = (mod8_prev * 10 + d) % 8
                new_state = (new_leading_zero, new_sum_mod3, new_has_3, new_mod8, new_tight)
                next_memo[new_state] = (next_memo[new_state] + cnt) % MOD
        memo[i + 1] = next_memo
    
    total = 0
    for state, cnt in memo[n].items():
        leading_zero, sum_mod3, has_3, mod8, _ = state
        if leading_zero:
            continue
        if (sum_mod3 == 0 or has_3) and mod8 != 0:
            total = (total + cnt) % MOD
    return total

def main():
    A, B = sys.stdin.readline().split()
    a_minus_1 = subtract_one(A)
    ans = (count(B) - count(a_minus_1)) % MOD
    print(ans)

if __name__ == '__main__':
    main()