S = eval(input())

T = eval(input())



min_count = len(T)

for s_i in range(len(S)):

    i = s_i

    matched = 0

    for j in range(len(T)):

        if len(S) <= i:  # Out of S

            matched = 0  # Cannot append characters to S

            break

        if S[i] == T[j]:

            matched += 1

        i += 1

    count = len(T) - matched

    if count < min_count:

        min_count = count

print(min_count)
S = eval(input())

T = eval(input())



min_count = len(T)

for s in range(len(S) - len(T) + 1):  # T cannot exceed the length of S

    matched = 0

    for i in range(len(T)):

        # print(f'S[{s + i}] == T[{i}]')

        if S[s + i] == T[i]:

            matched += 1

    count = len(T) - matched

    if count < min_count:

        min_count = count

print(min_count)
S = eval(input())
T = eval(input())
min_count = len(T)
for s_i in range(len(S)):
    i = s_i
    matched = 0
    for j in range(len(T)):
        if len(S) <= i:  # Out of S
            matched = 0  # Cannot append characters to S
            break
        if S[i] == T[j]:
            matched += 1
        i += 1
    count = len(T) - matched
    if count < min_count:
        min_count = count
print(min_count)

S = eval(input())
T = eval(input())
min_count = len(T)
for s in range(len(S) - len(T) + 1):  # T cannot exceed the length of S
    matched = 0
    for i in range(len(T)):
        # print(f'S[{s + i}] == T[{i}]')
        if S[s + i] == T[i]:
            matched += 1
    count = len(T) - matched
    if count < min_count:
        min_count = count
print(min_count)

-for s_i in range(len(S)): -    i = s_i +for s in range(len(S) - len(T) + 1):  # T cannot exceed the length of S -    for j in range(len(T)): -        if len(S) <= i:  # Out of S -            matched = 0  # Cannot append characters to S -            break -        if S[i] == T[j]: +    for i in range(len(T)): +        # print(f'S[{s + i}] == T[{i}]') +        if S[s + i] == T[i]: -        i += 1