#Matthew Modi
#Cary Academy INT-3
#ACSL Contest 2

import fileinput
import sys

ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

line_num = 0

def delshift(list, index = 0):
    newlist = []
    for i in range(0, index):
        newlist.append(list[i])
    for i in range(index + 1, len(list)):
        newlist.append(list[i])
    return newlist

def shorter(list1, list2):
    len1 = len(list1)
    len2 = len(list2)
    if len1 < len2:
        return len1
    else:
        return len2

for input_line in fileinput.input('input.txt'):
    try:
        line_num += 1

        s1 = [c for c in input_line.split()[0]]
        s2 = [c for c in input_line.split()[1]]

        iterations = 0
        while True:
            i = 0
            while shorter(s1, s2)>i:
                if s1[i] == s2[i]:
                    s1 = delshift(s1, i)
                    s2 = delshift(s2, i)
                    iterations = 0
                else:
                    i += 1
                    iterations += 1

            i = 0
            while (len(s1)>i+1 or len(s2)>i+1) and (len(s1)>i and len(s2)>i) and (s1[i] != s2[i]):
                if len(s2)>i+1 and s1[i] == s2[i+1]:
                    s2 = delshift(s2, i)
                    iterations = 0
                    break
                elif len(s1)>i+1 and s1[i+1] == s2[i]:
                    s1 = delshift(s1, i)
                    iterations = 0
                    break
                else:
                    i += 1
                    iterations += 1

            if iterations > 5:
                break
        
        asf = 0
        asf += abs(len(s1)-len(s2))
        for i in range(0, shorter(s1, s2)):
            asf += [c for c in ascii_uppercase].index(s1[i]) - [c for c in ascii_uppercase].index(s2[i])
        print(asf)
    except:
        print("Error on line " + str(line_num))