S = eval(input())

T = eval(input())

ans = float('inf')

for i2 in range(len(S)):

    if i2 + len(T) > len(S):

        break

    ans = min(ans, sum(S[i1] != T[i1 - i2] for i1 in range(i2, i2 + len(T))))

print(ans)

S = eval(input())

T = eval(input())

ans = float('inf')

for start in range(len(S) - len(T) + 1):

    ans = min(ans, sum(s != t for s, t in zip(S[start:], T)))

print(ans)

S = eval(input())
T = eval(input())
ans = float("inf")
for i2 in range(len(S)):
    if i2 + len(T) > len(S):
        break
    ans = min(ans, sum(S[i1] != T[i1 - i2] for i1 in range(i2, i2 + len(T))))
print(ans)

S = eval(input())
T = eval(input())
ans = float("inf")
for start in range(len(S) - len(T) + 1):
    ans = min(ans, sum(s != t for s, t in zip(S[start:], T)))
print(ans)

-for i2 in range(len(S)): -    if i2 + len(T) > len(S): -        break -    ans = min(ans, sum(S[i1] != T[i1 - i2] for i1 in range(i2, i2 + len(T)))) +for start in range(len(S) - len(T) + 1): +    ans = min(ans, sum(s != t for s, t in zip(S[start:], T)))