peterverebics/CodeNet_Python_118 huggingface dataset:
S = input()
T = input()

T1= T
Tlist =[]
countfront = 0
countback = 0
while T not in S:
  #if T not in S:
    #print (T,S)
  Tlist = list(T)
  Tlist.pop(0)
  T ="".join(Tlist)
  T.lstrip()
  #print (T)
  countfront+=1

Tlist = []
while T1 not in S:
  #if T1 not in S:
    #print (T1,S)
  Tlist = list(T1)
  Tlist.pop(0)
  T1 ="".join(Tlist)
  T1.lstrip()
  #print (T1)
  countback+=1
  
if countfront>countback:
  print (countback)
else :
  print (countfront)
S = input()
T = input()

if S.find(T) >= 0:
    print(0)
else:
    cnt = 1
    for _ in range(1, len(T)):
        for shift in range(cnt):
            if S.find(T[shift:shift - cnt]) >= 0:
                print(cnt)
                exit()
        cnt += 1

    print(cnt)
s = input()
t = input()

scnt = len(s)
tcnt = len(t)

change = 10**3

for i in range (0, scnt - tcnt):
  cnt = 0
  for j in range(tcnt):
    if s[i+j] != t[j]:
      cnt += 1
  if change > cnt:
    change = cnt

print(change)
a = input()
b = input()

l = []
for i in range(len(a) - len(b) + 1):
    cnt = 0
    for j in range(len(b)):
        if b[j] == a[i + j]:
            cnt += 1
    l.append(cnt)

print(l)
print(len(b) - max(l))
S = input().rstrip()
T = input().rstrip()
res = float("inf")
for i in range(len(S)-len(T)):
    t = 0
    for j in range(len(T)):
        if S[i+j]!=T[j]:
            t += 1
    res = min(t,res)
print(res)
S = input()
T = input()

N = len(T)

s_list = []
for i in range(len(S) - N + 1):
    s = S[i: i + N]
    s_list.append(s)

answer = N
for s in s_list:
    counter = 0
    for i in range(N):
        if s[i] != T[i]:
            counter += 1

answer = min(answer, counter)

print(answer)
s = list(input())
t = list(input())
tmp = 0
ans = len(t)
j_tmp = 0
for i in range(len(s) - len(t)):
    tmp = 0
    for j in range(len(t)):
        if s[i + j] != t[j]:
            tmp += 1
    if tmp < ans:
        ans = tmp
print(ans)
import sys

input = sys.stdin.readline
S = input().strip()
T = input().strip()

ans = float("inf")
ls = len(S)
lt = len(T)
for i in range(ls - lt + 1):
    tmp = 0
    for j in range(lt):
        if S[i+j] != T[j]:
            tmp += 1
    ans = min(ans, tmp)

print(tmp)
s = input()
t = input()
ans = 0
max = 0

if t in s:
  print(ans)
else:
  for i in range(len(s) - len(t) + 1):
    for j in range(len(t)):
      if t[j] == s[i]:
        ans += 1
        i += 1
      else:
        if max < ans:
          max = ans
        ans = 0
        i += 1
  print(len(t) - max)
import sys

def main():
    input = sys.stdin.readline
    s = input()
    t = input()

    res = len(t)
    # 部分文字列の探索
    for i in range(len(s)-len(t)+1):
        diff = 0
        for j in range(len(t)):
            if s[i + j] != t[j]:
                diff += 1
        res = min(res, diff)
    print(res)
if __name__ == '__main__':
    main()
S = input()
T = input()
n = len(T)
ans = len(T)
for st in range(0, len(S)-len(T)):
    SS = S[st:st+len(T)]
    tmp = len(T)
    for s,t in zip(SS,T):
        if s==t:
            tmp -= 1
        ans = min(ans, tmp)
print(ans)
s = input()
t = input()
r = len(s)
lon = len(t)
for i in range(len(s)-len(t)):
    c = 0
    for j in range(lon):
        if t[j]!=s[j+i]:
            c += 1
    if r >= c:
        r = c
print(r)
str = input()
part = input()

flg = False

for i in range(len(part)):
  for j in range(i + 1):
    # atcoder -> atcode
    # print(part[j:len(part)-i])
    target = str[j: -(i - j)]
    search = part[j: - (i - j)]
    if search in target:
      print(i)
      flg = True
      break
  
  if flg:
    break

if not flg:
	print(len(part))
S = input()
T = input()

S = list(S)
T = list(T)

result = len(T)-1
x = 0

for i in range(len(S)-len(T)+1):
    for j in range(len(T)):
        if S[i+j] != T[j]:
            x += 1
    if result > x:
        result = x
    x = 0

print(result)
S = input()
T = input()

max_count = 0
for start in range(len(T)):
    for end in range(start+1, len(T)):
        if T[start:end] in S[start:]:
            count = end - start
            max_count = max(max_count, count)
            # print(T[start:end], count)

answer = len(T) - max_count
print(answer)
import numpy as np

S=input()
T=input()

length = len(list(T))

max_score = 0
for i in range(len(list(S))-len(list(T))):
    tmp_T = np.array(list(T))
    tmp_S = np.array(list(S))[i:i+len(tmp_T)]
    score = np.zeros(len(tmp_T))
    score[tmp_T==tmp_S]=1
    score = np.sum(score)
    if max_score < score:
        max_score=score
print(int(length-max_score))
S = input()
T = input()

ans = 1000
for i in range(len(S) - len(T) + 1):
    tmp = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            tmp += 1
    ans = min(ans, tmp)
    print(i, ans)

print(ans)
S = input()
T = input()

count = 0
ans = len(T)

for i in range(len(T)):
    tmp = T[i:len(T)]
    if tmp in S:
        if ans > i:
            ans = i
for i in range(1,len(T)+1):
    tmp = T[0:i]
    if tmp in S:
        if ans > len(T) -i:
            ans = len(T) -i
            
print(ans)
import sys
input = sys.stdin.readline

def main():
    s = list( input() )
    t = list( input() )
    len_s = len( s )
    len_t = len( t )
    max = 0
    for i in range( len_s - len_t + 1 ):
        same = 0
        
        for j in range( len_t ):
            if s[ i + j ] == t[ j ]:
                same += 1

        if same > max:
            max = same
    
    print( len_t - max )

main()
import sys
input = sys.stdin.readline
S = input()
T = input()
if len(S) - len(T) > 0:
  score_list = []
  for i in range(len(S) - len(T)):
    s = S[i:i+len(T)]
    score = 0
    for i in range(len(s)):
      if s[i] != T[i]:
        score += 1
    score_list.append(score)
  print(min(score_list))
def l_in(type_): return list(map(type_, input().split()))
def i_in(): return int(input())
def m_in(type_): return map(type_, input().split())
def r_in(n, type_): return [type_(input()) for _ in range(n)]
ans = 0

s = input()
t = input()
l = len(t)

mx = 0
for idx, _ in enumerate(s[:-l]):
    word = ''
    for i in range(l):
        word += s[idx+i]
    x = 0
    for a, b in zip(word, t):
        if a == b: x += 1
    if x > mx: mx = x

ans = l - mx

print(ans)
import sys
input = sys.stdin.readline

S= input().rstrip('\n')
T= input().rstrip('\n')
res = 0
check = 0
for x in range(len(T),0,-1):
  for i in range(len(T)-x):
    l = len(T)-i-x-1
    if T[i:i+x] in S[i:len(S)-l]:
      res += len(T)-x
      check += 1
      break
  if check>0:
    break
print(res)
s = input()
t = input()
ans = 1000
for i in range(len(s) - len(t)):
    c = 0
    f = 0
    for j in range(i, i + len(t)):
        if s[j] != t[f]:
            c += 1
        f += 1
    ans = min(ans, c)
print(ans)
s = input()
t = input()

len_t = len(t)

ans = 9999
for i in range(len(s)-len(t)):
    count = 0
    for j in range(len_t):
        if s[i+j]!=t[j]:
            count+=1
    ans = min(ans,count)
print(ans)
s=input()
t=input()

slen=len(s)
tlen = len(t)
min = tlen

for i in range(slen - tlen):
    count = 0
    for j in range(tlen):
        if s[i + j] != t[j]:
            count += 1
    if count < min:
        min = count

print(min)
S = input()
T = input()

count = 0
max_count = 0

for i in range(len(S) - len(T)):
    for j in range(len(T)):
        if S[i+j] == T[j]:
            count += 1
            if max_count <= count:
                max_count = count
        if j == (len(T) -1):
            count = 0

print(len(T) - max_count)
s = input()
t = input()

def count_ans(a,b):    
    ans = 0
    for k in range(len(a)):
        for l in range(len(b)-k):
            if k==l and a[k]==b[l]:
                ans += 1
    return ans

ans = 0
for i in range(len(s)-len(t)+1):
    Ans = count_ans(s[i:i+len(t)],t)
    if ans < Ans:
        ans = Ans

print(len(t)-ans)
S = input()
T = input()

for i in range(len(T)):
    lT = len(T)-i+1
    sT = 0
    while lT != len(T)+1:
        if T[sT:lT] in S[sT:len(S)]:
            print(i)
            exit()
        else:
            sT += 1
            lT += 1

print(len(T))
S = input()
T = input()
ans = 0
fin = 0
if (T in S):
    print(0)
else:
    for i in range(len(T)):
        if fin == 1:
            break
        else:
            ans += 1
            for j in range(len(T)):        
                tmp = T[:j] + T[j+i +1:]
                if (tmp in S):
                    print(ans)
                    fin = 1
                    break
s = list(input())
t = list(input())
m = len(t)
for i in range(len(s)-len(t)+1):
    c = 0
    target = s[i:i+len(t)]
    print(target)
    for j in range(len(t)):
        print(target[j],t[j])
        if not target[j] == t[j]:
            c += 1
    print(m,c)
    if c < m :
        m = c
print(m)
s = input()
t = input()

ans = len(t)

for i in range(len(s) - len(t)):
    cnt = len(t)
    for j in range(len(t)):
        if s[i + j] == t[j]:
            cnt -= 1
    if cnt < ans:
        ans = cnt

print(ans)
S=input()
T=input()
ans=len(T)

for j in range(len(S)-len(T)):
    total=0
    for i in range(len(T)):
        if S[i+j]!=T[i]:
            total+=1
    if ans>=total:
        ans=total
        
print(ans)
S = input()
T = input()
ans = float('inf')
for i in range(len(S)-len(T)):
    st = S[i:len(T)+i]
    count = 0
    for j in range(len(T)):
        if st[j]!=T[j]:
            count+=1
    ans = min(ans,count)
print(ans)
S=input()
LS=len(S)
T=input()
LT=len(T)
tmp=0
ans=LT
for i in range(LS-LT):
  for j in range(LT):
    if S[i+j]!=T[j]:
      tmp+=1
  ans=min(tmp,ans)
  tmp=0
print(ans)
# Python template 
from collections import defaultdict 
import sys
import math 

def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()


s = input()
t = input()


ans = math.inf 
for i in range(len(s)-len(t)):
    cnt = 0
    for j in range(len(t)):
        if t[j] != s[i+j]:
            cnt+=1
    ans = min(cnt,ans)
print(ans)
s=input()
t=input()
a=len(s)
b=len(t)
ans=1001
kari=0
k=0
for i in range(0,a-b):
    kari=0
    k=0
    for j in t:
        if j!=s[i+k]:
            kari+=1
        k+=1
    if ans>kari:
        ans=kari
print(ans)
S = input()
T = input()


max_diff = 0
window = len(T)
for i in range(0, len(S) - window + 1):
    x = S[i: i+window]
    count = 0
    for a, b in zip(T, x):
        if a != b:
            count += 1
    max_diff = max(count, max_diff)
print(max_diff)
S = input()
T = input()
temp = T
ans = 0
ret = False
t = list(T)
s = list(S)
t_ans = len(t)
f_ans = len(t)
for i in range(len(t)):
    for k in range(len(t) - len(T)):
        if T in S[k:k + len(T)]:
            print(len(t) - len(T))
            ret = True
if not ret:
    print(len(t))
def subst(S, T)-> int:
  lenT = len(T)
  result = lenT
  for i in range(len(S) - lenT):
    # tempS = S[i-lenT]
    tempResult = 0
    for j in range(lenT):
      if T[j] != S[j + i]:
        tempResult += 1
    if tempResult < result:
      result = tempResult
    
  return result

if __name__ == "__main__":
  S = input()
  T = input()
  print(subst(S, T))
S = input()
T = input()
assert len(S) <= 1000
assert len(T) <= 1000
assert len(T) <= len(S)
len_T = len(T)
max_count = 0
for i in range(len(S)-len_T):
    count = 0
    for j in range(len_T):
        count += int(T[j] == S[i+j]) 
    max_count = max(count, max_count)
print(len_T - max_count)
S = input()
T = input()

lens = len(S)
lent = len(T)

ans = lent

for i in range(lens - lent):
  count = 0
  for j in range(lent):
    if S[i+j] != T[j]:
      count = count + 1

  if count < ans:
    ans = count
    
print(ans)
s = input()
t = input()
cnt = 0
max = 0
for i in range(len(s)-len(t)):
  cnt = 0
  for j in range(len(t)):
    if s[i] == t[j]:
      cnt += 1
      if cnt > max:
        max = cnt
    else:
      break
print(len(t)-max-1)
s=str(input())
t=str(input())

n=len(t)
ans=0
for k in range(1,len(t)+1):
    for i in range(n-k+1):
        if(t[i:i+k] in s):
            ans=k
        
print(n-ans)
s=input()
t=input()

result = 0
for i in range(len(s)):
  count = 0
  flg = False
  for j in range(len(t)):
    if i+j > len(s)-1:
      break
    if t[j] == s[i+j]:
      flg = True
    else:
      flg = False

    if flg:
      count += 1
      
  result = max(result,count)
print(len(t)-result)
S = input()
T = input()

minChangeCounter = 1000000

for i in range(len(S) - len(T)):
    substr = S[i:i + len(T)]
    changeCounter = 0
    for j in range(len(T)):
        if not substr[j] == T[j]:
            changeCounter += 1
    if changeCounter < minChangeCounter: minChangeCounter = changeCounter

print(minChangeCounter)
s = input()
t = input()
ans = 0
max = 0

if t in s:
  print(ans)
else:
  for i in range(len(s) - len(t)):
    for j in range(len(t)):
      if t[j] == s[i]:
        ans += 1
      else:
        if max < ans:
          max = ans
        ans = 0
  print(len(t) - max)
import sys
input = sys.stdin.readline
S = input()
T = input()
if len(S) - len(T) > 0:
  score_list = []
  for i in range(0, len(S) - len(T) + 1):
    s = S[i:i+len(T)]
    if len(s) != len(T):
      continue
    score = sum([1 if s[i]==T[i] else 0 for i in range(len(s))])
    score_list.append(score)
  print(len(T) - max(score_list))
else:
  score = sum([1 if S[i]==T[i] else 0 for i in range(len(S))])
  print(len(T) - score)
s = input()
t = input()

ans = len(t)
for i in range(len(s) - len(t)):
    count = 0
    for j in range(len(t)):
        if s[j+i] != t[j]:
            count += 1
    ans = min(ans, count)
print(ans)
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(1000000)
from collections import deque
import re

S=input()
T = input()

snum = len(S)
tnum = len(T)

m = tnum

for start in range(snum - tnum + 1):
    diff = 0
    for i in range(tnum):
        if S[start+i] != T[i]:
            diff += 1
    m = min(tnum, diff)

print(m)
def resolve():
    S = input()
    T = input()
    mincnt = float("inf")
    for ptr in range(len(S)-len(T)):
        cnt = 0
        for i in range(len(T)):
            sptr = ptr + i
            if S[sptr] != T[i]:
                cnt += 1
        mincnt = min(cnt, mincnt)
    print(mincnt)



    
if '__main__' == __name__:
    resolve()
def resolve():
    S = input()
    T = input()
    for matches in range(len(T), 0, -1):
        for ptr in range(len(T)):
            if ptr+matches > len(T):
                break
            subt = T[ptr:ptr+matches]
            if subt in S[ptr:]:
                print(len(T)-matches)
                return
    print(len(T))



    
if '__main__' == __name__:
    resolve()
s = input()
t = input()

def find_common(s1, s2):
    count = 0
    for c,y in zip(s1, s2):
        if c == y:
            count += 1
    return count

start = 0 
end =  len(t)
ans  = 0
while end < len(s):
    ans  = max(ans, find_common(t, s[start:end]))
    start+=1
    end+=1
print(len(t)- ans)
s=input()
t=input()
if t in s:
  print(0)
else:
  ans=100000
  num=len(s)-len(t)
  for i in range(num):
    r=0
    for j in range(len(t)):
      
      if s[i+j]!=t[j]:
        r+=1
    if r<ans:
      ans=r
  print(ans)
S = input()
T = input()

c = len(S) - len(T)

m = 1000
for i in range(c):
    count = 0
    for s, t in zip(S[i:], T):
        if s != t:
            count += 1
    m = min(m, count)
print(m)
s = input()
t = input()


s_len = len(s)
t_len = len(t)
ans = s_len
for i in range(0,s_len):
    tmp = 0
    for j in range(0,t_len):
        if i+j >= s_len:
            continue
        if s[i+j] != t[j]:
            tmp = tmp + 1
    ans = min(tmp,ans)

print(ans)
S=input()
T=input()
m=2000
for i in range(len(S)-len(T)):
    U=S[i:i+len(T)]
    c=0
    for j in range(len(T)):
        if U[j]!=T[j]:
            c+=1
    m=min(c,m)
print(m)
S = list(input())
T = list(input())
array = [0. for i in range(len(S))]
count = 0

for i in range(len(S)):
    for j in range(len(T)):
        if S[i] == T[j] and i >= j:
            count += 1
            array[i] += count
            break
        else:
            count = 0
print(int(len(T)-max(array)))
S = input()
T = input()

lent = len(T)
ans = lent
for i in range(len(S)-lent):
    s = S[i:i+lent]
    lev = 0
    lev = sum(map(lambda x: x[0] != x[1], zip(s, T)))
    if lev == 0:
        ans = 0
        break
    elif lev < ans:
        ans = lev
print(ans)
S = input()
T = input()
amount = 0
for i in range(len(T)-1):
    for j in range(i+1,len(T)+1):
        tmp = T[i:j]
        if tmp in S[i:] and amount < len(tmp):
            amount = len(tmp)
print(len(T)-amount)
s = input()
t = input()
n = len(s) - len(t) + 1
ans = 1000
for i in range(n):
    temp = 0
    for j in range(len(t)):
        if t[j] != s[j+i]:
            temp += 1
        ans = min(temp,ans)
print(temp)
S = input()
T = input()

S_list = list(S)
T_list = list(T)
answer = 1000

for i in range(len(S_list)-len(T_list)+1):
    count = 0
    for j in range(len(T_list)):
        if(S_list[i] != T_list[j]):
            count +=1
            i += 1
    answer = min(count, answer)
print(answer)
s=input()
t=input()
y=len(t)
z=len(s)
for i in range(0,(z-y+1)):
    xx=i+y
    s1=s[i:xx]
    ct=0
    yy=y
    for j in range(0,y):
        if(s1[j]==t[j]):
            ct+=1
    z=y-ct
    if(z<yy):
        yy=z
print(yy)
S = input()
T = input()

s = len(S)
t = len(T)

ans = 10**9

for i in range(s - t):
    tmp = 0
    for j in range(t):
        if S[i + j] != T[j]:
            tmp += 1

    ans = min(ans, tmp)

print(ans)
S = input()
T = input()
ans = len(T)
for i in range(len(S)-len(T)):
    diff = 0
    for j in range(len(T)):
        if T[j] != S[i + j]:
            diff = diff + 1
    ans = min(ans, diff)

print(ans)
s = input()
t = input()

ls = len(s)
lt = len(t)

ans = ls

for i in range(0, lt):

    for j in range(0, lt - i + 1):
        r = t[i:i+j]
        
        if r in s[i:ls-j]:
            
            a = lt - len(r)
            if a < ans:
                ans = a

print(ans)
S = input()
T = input()

for i in range(len(T), 0, -1):
    for j in range(len(T)-i+1):
        subst = T[j:i+j]
#        print(subst)
        if S.find(subst, j, len(S)-(len(T)-i-j))>=0:
            print (len(T)-i)
#            print(subst)
            exit(0)
import sys

input = sys.stdin.readline


def main():
    S = input()
    T = input()
    N = len(S)
    M = len(T)
    ans = float('inf')
    for i in range(N - M):
        cnt = 0
        for j in range(M):
            if T[j] != S[i:(i + M)][j]:
                cnt += 1
        ans = min(ans, cnt)
    print(ans-1)


if __name__ == '__main__':
    main()
import sys
input = sys.stdin.readline
S = input().strip()
T = input().strip()


N = len(S)
M = len(T)

ans = 10**10
for i in range(N-M):
    subS = S[i:i+M]
    temp = 0
    for s,t in zip(subS, T):
        if s != t:
            temp += 1
    ans = min(temp,ans)

print(ans)
import re

S = input()
T = input()
k = 0 

# if re.search(T, S):
#     print(0)
# else:
for i in S:
    k +=1
    if re.search(T[0:len(T)-(k+1)], S):
        break
    

print(k)
s = str(input())
t = str(input())
cnt = 0
max = 0
for i in range(len(s)-len(t)+1):
  if max < cnt:
    max = cnt
  cnt = 0
  for j in range(len(t)):
    if s[j+i] == t[j]:
      cnt += 1
print(len(t)-cnt)
s = input()
t = input()
cnt = 0
ans = 0
while cnt < len(s) - len(t):
    chk = 0
    for i, j in zip(range(cnt,cnt+len(t)),range(len(t))):
        if s[i] == t[j]:
            chk += 1
    ans = max(ans,chk)
    cnt += 1

print(len(t) - ans)
s = input()
t = input()

ans = float("inf")
flag = False
for i in range(len(s)-len(t)):
    curr = 0
    for j in range(len(t)):
        # if i + j >= len(s):
        #     flag = True
        #     break
        if t[j] != s[i + j]:
            curr += 1
    # if flag:
    #     break
    ans = min(ans, curr)
print(ans)
s = input()
t = input()

res = len(t)

for i in range(len(s)-len(t)):
    tmp=len(t)
    for j in range(len(t)):
        if(s[i+j] == t[j]):
            tmp -= 1
    if res > tmp:
        res = tmp

print(res)
s=list(input())
t=list(input())
m=len(t)
for i in range(len(s)-len(t)):
    ma=0
    for j in range(len(t)):
        if s[i+j]!=t[j]:
            ma+=1
    if ma <m:
        m=ma
print(m)
s1 = input()
s2 = input()

i = 0
j = len(s2)
m = len(s2)
while j < len(s1):
  c = 0
  for k in range(len(s2)):
    if s2[k] == s1[k+i]:
      c+=1
  j += 1
  i += 1
  m = min(m, len(s2)-c)

print(m)
s=input()
t=input()
n=len(s)-len(t)-1
ans=len(t)
for i in range(n):
    cnt=0
    for j in range(len(t)):
        if s[i+j]!=t[j]:
            cnt+=1
    ans=min(ans,cnt)
print(ans)
import sys
import math

S = list(str(input()))
T = list(str(input()))

ans = len(T)
for i in range(len(S) - len(T)):
    change = 0
    for j in range(len(T)):
        # print(f'i {i}, j {j}')
        if T[j] != S[i + j]:
            change += 1

    ans = min(ans, change)

print(ans)
s=list(input())
t=list(input())
S=len(s)
T=len(t)
count=0
ans=1000
for i in range(S-T):
  count=0
  for j in range(T):
    if s[i+j]!=t[j]:
      count+=1
  ans=min(ans,count)
print(ans)
S=input()
T=input()
c=len(T)
for i in range(len(S)-len(T)):
  d=0
  for j in range(len(T)):
    if S[i+j]!=T[j]:
      d+=1
  if d<c:
    c=d
print(c)
from collections import deque
import sys, copy, itertools,heapq
input = sys.stdin.readline
 
S = input()
T = input()
s = len(S)
t = len(T)
#A=[0]*(len(S))

ans = float('inf')
for i in range(len(S)-len(T)+1):
  x = 0
  for j in range(len(T)):
    if S[i+j] != T[j]:
      x += 1
  ans = min(ans, x)

#print(s)
#print(t)
#print(A)
print(ans)
S = input()
T = input()

max_len = 0
for i in range(len(S)):
  len_ = 0
  for s, t in zip(S[i:], T):
    if s == t:
      len_ += 1
    else:
      pass
  max_len = max(max_len, len_)
print(len(T) - max_len)
s=input()
t=input()
n=len(t)
ans=len(t)

for i in range(len(s)-len(t)):
    tmp=0
    for j in range(len(t)):
        if s[i+j]!=t[j]:
            tmp+=1
    ans=min(ans,tmp)
print(ans)
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()

def main():
    s = input()
    t = input()

    li = set()
    for i in range(len(t)):
        li.add(t[i])
        li.add(t[i:])
        li.add(t[:i])
    for el in sorted(li, key=lambda x: len(x), reverse=True):
        if el in s:
            print(len(t) - len(el))
            return
    print(len(t))

if __name__ == '__main__':
    main()
s=input()
a=len(s)
t=input()
b=len(t)
maxcnt=0
for i in range(a-b):
	count=0
	for j in range(b):
		s1=s[i+j]
		s2=t[j]
		if(s1==s2):
			count+=1
	if(maxcnt<count):
		maxcnt=count	
print(b-maxcnt)
S = input()
T = input()

lent = len(T)
ans = lent
for i in range(len(S)-lent+1):
    s = S[i:i+lent]
    lev = 0
    lev = sum(map(lambda x: x[0] != x[1], zip(s, T)))
    print(s)
    print(lev)
    if lev == 0:
        ans = 0
      #  break
    elif lev < ans:
        ans = lev
print(ans)
s = input()
t = input()

t_len = len(t)
s_len = len(s)
max_ = 0
temp = 0

for i in range(s_len - t_len):
  for j in range(t_len):
    if s[i + j] == t[j]:
      temp += 1
  if max_ < temp:
    max_ = temp
print(t_len - max_ + 1)
S=str(input())
S=list(map(str,S))
T=str(input())
T=list(map(str,T))
Ca=len(T)
for i in range(len(S)-len(T)+1):
  Cb=len(T)
  for j in range(len(T)):
    if S[i+j]==T[j]:
      Cb-=1
  if Ca>Cb:
    Ca=Cb
print(Cb)
S = input()
T = input()

answer = 100000
for i in range(len(S) - len(T)):
    distance = 0
    for j in range(len(T)):
        if S[i + j] != T[j]:
            distance += 1
    if answer > distance:
        answer = distance
print(answer)
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    S = input()
    T = input()
    LS = len(S)
    LT = len(T)
    ans = 0
    for i in range(LS-LT):
        tmp = 0
        for s, t in zip(S[i:i+LT],T):
            if s==t:
                tmp += 1
        ans = max(ans, tmp)
    print(LT-ans)


if __name__ == '__main__':
    main()
s=input()
t=input()
ans=len(t)
for i in range(len(s)-len(t)):
    cnt=0
    for j in range(len(t)):
        if s[i+j]!=t[j]:
            cnt+=1
    ans=min(ans,cnt)
print(ans)
S = input()
T = input()

ans = len(T)

for i in range(len(T)):
    for j in range(i + 1, len(T) + 1):
        if T[i:j] in S[i:-(len(T) - j)]:
            if len(T) - len(T[i:j]) < ans:
                ans = len(T) - len(T[i:j])

print(ans)