# Arup Guha
# 9/15/2025
# Solution to 2025 UCF Locals Problem: Twin Numbers

# Returns an integer equal to the number of twin numbers less than or equal
# to the number stored in s. Assumes s is of even length.
def atOrBelow(s):

    # I don't like using the keyword global...weird I know.
    MOD = 10007

    # Store result as digits.
    t = [0]*(len(s)//2)

    # We may end up setting the rest of the digits left to all 9s.
    allNines = False

    # Go in pairs.
    for i in range(0, len(s), 2):

        # Easy case.
        if allNines:
            t[i//2] = 9

        # We take the minimum of the digits and then we'll do all 9s.
        # Basically 22xx... is less than 23wyz...
        elif s[i] < s[i+1]:
            t[i//2] = ord(s[i])-ord('0')
            allNines = True

        # Here we must go under s[i] but then anything works.
        # Basically 55xx... is less than 60wyz...
        elif s[i] > s[i+1]:
            t[i//2] = ord(s[i])-1-ord('0')
            allNines = True

        # This is a push, match it exactly and continue.
        else:
            t[i//2] = ord(s[i])-ord('0')

    # How to interpret a digit by digit number under mod.
    res = 0
    for i in range(len(t)):
        res = (10*res + t[i])%MOD
    
    return res

# Assumes s is even length.
def isTwin(s):

    # Not a twin if any of these pairs don't match.
    for i in range(0,len(s),2):
        if s[i] != s[i+1]:
            return False

    # We're good if we get here.
    return True

# I really need to learn how to do global things in Python.
MOD = 10007

# Get the bounds.
lo = input().strip()
hi = input().strip()

# Fix lengths if necessary.
if len(lo)%2 == 1:
    lo = "0"+lo
if len(hi)%2 == 1:
    hi = "0"+hi

# Initial answer.
res = ( atOrBelow(hi) - atOrBelow(lo) + MOD )%MOD

# Special case.
if isTwin(lo):
    res += 1

# Ta da!
print(res%MOD)
        
