S, T = eval(input()), eval(input())

print((min([sum([0 if x == y else 1 for x, y in zip(S[i:i + len(T)], T)]) for i in range(len(S) - len(T) + 1)])))

S, T = eval(input()), eval(input());print((min([sum([0 if x == y else 1 for x, y in zip(S[i:], T)]) for i in range(len(S) - len(T) + 1)])))

S, T = eval(input()), eval(input())
print(
    (
        min(
            [
                sum([0 if x == y else 1 for x, y in zip(S[i : i + len(T)], T)])
                for i in range(len(S) - len(T) + 1)
            ]
        )
    )
)

S, T = eval(input()), eval(input())
print(
    (
        min(
            [
                sum([0 if x == y else 1 for x, y in zip(S[i:], T)])
                for i in range(len(S) - len(T) + 1)
            ]
        )
    )
)

-                sum([0 if x == y else 1 for x, y in zip(S[i : i + len(T)], T)]) +                sum([0 if x == y else 1 for x, y in zip(S[i:], T)])