# Lynn Jegal
# Bergen County Academies
# Intermediate Division

file_1 = open("2int_sampledata.txt", "r")
input = file_1.read().split()

num = len(input)/2 # number of times loop should be run
count = 0


# delete like characters
def del_like_chars(s1, s2):
    pos = 0
    changed = False

    while pos < min(len(s1), len(s2)):
        # if characters match at position pos, remove the characters.
        if s1[pos] == s2[pos]:
            s1 = s1[:pos] + s1[(pos + 1):]
            s2 = s2[:pos] + s2[(pos + 1):]
            changed = True
        else:
            pos += 1

    return s1, s2, changed


# if a letter can be removed to make a character match, delete
def shift_chars(s1, s2):
    pos = 0
    changed = False

    while pos + 1 < min(len(s1), len(s2)):

        if s1[pos] == s2[pos+1]:
            # delete the character at position "pos" s2
            s2 = s2[:pos] + s2[(pos + 1):]
            changed = True
            return s1, s2, changed

        elif s2[pos] == s1[pos+1]:
            # delete the character at position "pos" s1
            s1 = s1[:pos] + s1[(pos + 1):]
            changed = True
            return s1, s2, changed
        else:
            pos += 1

        # if one string is larger than the other
        if len(s1) < len(s2):
            if s1[len(s1)-1] == s2[len(s1)]:
                s2 = s2[:(len(s1) - 1)] + s2[len(s1):]
                changed = True
                return s1, s2, changed

        elif len(s2) < len(s2):
            if s2[len(s2)-1] == s2[len(s2)]:
                s1 = s1[:len(s2) - 1] + s1[len(s2):]
                changed = True
                return s1, s2, changed

    return s1, s2, changed


# calculate ACSL Sameness Factor
def sameness_factor(s1, s2):
    asf = abs(len(s1) - len(s2))

    pos = 0
    while pos < min(len(s1), len(s2)):
        asf += ord(s1[pos]) - ord(s2[pos])
        pos += 1

    return asf


while count < num:
    str1 = input[2*count]
    str2 = input[2*count + 1]
    change1, change2 = True, True

    while change1 == True or change2 == True:
        str1, str2, change1 = del_like_chars(str1, str2)
        str1, str2, change2 = shift_chars(str1, str2)

    asf_value = sameness_factor(str1, str2)

    print(str(count+1) + ". " + str(asf_value))

    count += 1