#Sarah Grebe
#Feb 4, 2020
#Int5
#Enloe
#Potter


filename = 'F:\\2inttest.txt'
##filename = 'inttest.txt'

with open(filename) as file_object:
    lines = file_object.readlines()

for line in lines:
    words = line.split()
    word1 = words[0].upper()
    word2 = words[1].upper()

    end1 = False
    i=0
    while end1 == False:
        if i == len(word1)-1 or i == len(word2)-1:
            end1 = True
            done1 = True
        if word1[i] == word2[i]:
            word1 = word1[:i] + word1[i+1:]
            word2 = word2[:i] + word2[i+1:]
            i=0
        else:
            i+=1
    done1 = False
    done2 = False
    while done1 == False or done2 == False:
        j=0
        while j <= len(word1)-2 and j <= len(word2)-2:
##            print("test1", word1, word2)
            if word1[j] == word2[j+1]:
                word2 = word2[:j] + word2[j+1:]
                j = len(word1)
            elif word2[j] == word1[j+1]:
                word1 = word1[:j] + word1[j+1:]
                j = len(word1)
            else:
                j+=1
                if j == len(word1)-1 or j == len(word2)-1:
                    done1 = True
                    
##        print("test2", word1, word2)              
        len1 = len(word1)
        len2 = len(word2)
        if len1 > len2 and len2 > 0:
            if word2[len2-1] == word1[len2]:
                word1 = word1[:len2-1] + word1[len2:]
        elif len1 < len2 and len1 > 0:
            if word1[len1-1] == word2[len1]:
                word2 = word2[:len1-1] + word2[len1:]
                
        i=0
        done2 = True    
        while i <= len(word1)-1 and i <= len(word2)-1:
##            print("test3", word1, word2)
            if word1[i] == word2[i]:
                word1 = word1[:i] + word1[i+1:]
                word2 = word2[:i] + word2[i+1:]
                i=0
                done2 = False
            else:
                i+=1
        if len(word1) <= 1 or len(word2) <= 1:
            done1 = True
            done2 = True
        
##    print(word1, word2)

    letters = {'A':1, 'B':2, 'C':3, 'D':4, 'E':5, 'F':6, 'G':7, 'H':8, 'I':9,
               'J':10, 'K':11, 'L':12, 'M':13, 'N':14, 'O':15, 'P':16, 'Q':17,
               'R':18, 'S':19, 'T':20, 'U':21, 'V':22, 'W':23, 'X':24, 'Y':25, 'Z':26}
    ASF = abs(len(word2)-len(word1))
    i=0
    while i != len(word1) and i != len(word2):
        ASF += letters[word1[i]] - letters[word2[i]]
        i+=1
    print(ASF)