# Will Wang - 12th Grade
# Pittsford Sutherland High School
# American Computer Science League - Intermediate Division
# Contest 2
# PYTHON 3


def remove_same(arr1, arr2):
    if len(arr1) <= len(arr2):
        iter_length = len(arr1)
    else:
        iter_length = len(arr2)

    for c in range(iter_length):
        if arr1[c] == arr2[c]:
            del arr1[c]
            del arr2[c]
            break

    return arr1, arr2


def remove_next(arr1, arr2):
    if len(arr1) <= len(arr2):
        iter_length = len(arr1)
    else:
        iter_length = len(arr2)

    for c in range(iter_length):
        if c < len(arr2)-1:
            if arr1[c] == arr2[c + 1]:
                del arr2[c]
                break
        if c < len(arr1)-1:
            if arr1[c + 1] == arr2[c]:
                del arr1[c]
                break

    return arr1, arr2


def solve(string1, string2):
    arr1 = list(string1)
    arr2 = list(string2)
    score = 0
    while True:
        arr1_prev = arr1[:]
        arr2_prev = arr2[:]
        for j in range(len(arr1)):
            arr1, arr2 = remove_same(arr1, arr2)

        arr1, arr2 = remove_next(arr1, arr2)
        if arr1_prev == arr1 and arr2_prev == arr2:
            break

    if len(arr1) <= len(arr2):
        iter_len = len(arr1)
    else:
        iter_len = len(arr2)
    for p in range(iter_len):
        score += ord(arr1[p]) - ord(arr2[p])

    return score + (abs(len(arr1) - len(arr2)))


for i in range(5):
    inp = input().split()
    str1 = inp[0]
    str2 = inp[1]
    ans = solve(str1, str2)
    print(ans)