s = input().strip()
t = input().strip()

n = len(s)
m = len(t)

min_operations = float("inf")

for i in range(m - n + 1):
    sub_t = t[i : i + n]
    operations = 0
    for c1, c2 in zip(s, sub_t):
        if c1 != c2:
            diff = abs(ord(c1) - ord(c2))
            operations += min(diff, 26 - diff)
            if operations >= min_operations:
                break  
    if operations < min_operations:
        min_operations = operations

print(min_operations)