# Anthony Li
# Bergen County Academies
# Intermediate

from typing import Optional, Tuple

def remove_char(string: str, index: int) -> str:
    return string[:index] + string[index+1:]

def remove_like_characters(a: str, b: str) -> Optional[Tuple[str, str]]:
    i = 0
    aResult = a
    bResult = b
    didDelete = False
    while i < min(len(aResult), len(bResult)):
        if aResult[i] == bResult[i]:
            aResult = remove_char(aResult, i)
            bResult = remove_char(bResult, i)
            didDelete = True
        else:
            i += 1
    
    return (aResult, bResult) if didDelete else None

def find_offset_characters(string: str, compare: str) -> Optional[int]:
    for i in range(min(len(string) - 1, len(compare))):
        if string[i + 1] == compare[i]:
            return i

    return None

def solve(a: str, b: str) -> int:
    aCurrent = a
    bCurrent = b
    didDelete = True
    while didDelete:
        likeResult = remove_like_characters(aCurrent, bCurrent)
        if likeResult is not None:
            # pylint: disable=unpacking-non-sequence
            aCurrent, bCurrent = likeResult
        
        aIndex = find_offset_characters(aCurrent, bCurrent)
        bIndex = find_offset_characters(bCurrent, aCurrent)
        
        if aIndex is None and bIndex is None:
            if likeResult is None:
                didDelete = False
        elif aIndex is None or (bIndex is not None and bIndex <= aIndex):
            bCurrent = remove_char(bCurrent, bIndex)
        else:
            aCurrent = remove_char(aCurrent, aIndex)

    asf = abs(len(aCurrent) - len(bCurrent))
    for i in range(min(len(aCurrent), len(bCurrent))):
        asf += ord(aCurrent[i]) - ord(bCurrent[i])

    return asf

file = open("2int_sampledata.txt", "r")
for i in range(5):
    line = file.readline().replace("\n", "").replace("\r", "").split(" ")
    print(solve(line[0], line[1]))

file.close()