Problem:
 Score : 200 points    Problem Statement Given are two strings S and T .  Let us change some of the characters in S so that T will be a substring of S .  At least how many characters do we need to change?  Here, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy , but not a substring of xxyxx .      Constraints  The lengths of S and T are each at least 1 and at most 1000 .  The length of T is at most that of S .  S and T consist of lowercase English letters.         Input Input is given from Standard Input in the following format:  S  T       Output Print the minimum number of characters in S that need to be changed.        Sample Input 1 cabacc
abc      Sample Output 1 1  For example, changing the fourth character a in S to c will match the second through fourth characters in S to T .  Since S itself does not have T as its substring, this number of changes - one - is the minimum needed.       Sample Input 2 codeforces
atcoder      Sample Output 2 6

Solution (Python):
s = input()
t = input()
ans = 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
    ans = min(diff,ans)
print(ans)

Solution (Python):
S,T=input(),input()
S_l=len(S)
T_l=len(T)
score=[]

for i in range(S_l-T_l+1):
  score_1=0
  S0=S[i:i+T_l]
  for j in range(T_l):
    if T[j]==S0[j]:
      score_1=score_1+1
  score.append(T_l-score_1)

print(min(score))

Solution (Python):



def solve(S, T):
    ans = len(T)

    
    for i in range(len(S) - len(T) + 1):
        target = S[i:]
        diff = 0

        
        for j in range(len(T)):
            if target[j] != T[j]:
                diff += 1

        ans = min(ans, diff)

    return ans


def main():
    S = input()
    T = input()
    result = solve(S, T)
    print(result)


if __name__ == "__main__":
    main()

Solution (Python):
s = input().rstrip()
t = input().rstrip()
count = 0
min_count = 10000
for i in range(len(s) - len(t) + 1):
    s_selected = s[i:i + len(t)]
    
    count = 0
    for j in range(len(t)):
        if t[j] != s_selected[j]:
            count += 1
    
    if count < min_count:
        min_count = count
print(min_count)

Solution (Python):
s = input()
t = input()

ans = 1001
for i in range(len(s) - len(t) + 1):
    num = 0
    x = s[i : i + len(t)]

    for j in range(len(t)):
        if x[j] != t[j]:
            num += 1

    ans = min(ans, num)

print(ans)

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

Solution (Python):
s = input()
t = input()
 
ans = 10000
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(ans)

Solution (Python):
S = input()
T = input()

L = len(T)
ans = 0

for i in range(len(S)-L+1):
    cnt = 0
    for j in range(L):
        
        if S[i+j] == T[j]:
            cnt += 1
        ans = max(ans,cnt)
        
print(L-ans)

Solution (Python):
s=input()
t=input()
c=0
for i in range(len(s)-len(t)+1):
    x=s[i:i+len(t)]
    tmp=0
    for j in range(len(t)):
        if x[j]==t[j]:
            tmp+=1
    if c<tmp:
        c=tmp
print(len(t)-c)

Solution (Python):
S = input()
T = input()

ans = len(T)

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

Solution (Python):
s = input()
t = input()
S,T = len(s),len(t)
ans = T
for i in range(S-T+1):
    tmp = [c1!=c2 for c1,c2 in zip(s[i:i+T],t)].count(True)
    ans = min(ans,tmp)
print(ans)

Solution (Python):
s = input()
t = input()
ns = len(s)
nt = len(t)
ans = float("inf")

for i in range(ns-nt+1):
    res = 0
    
    for j in range(nt):
        if t[j] != s[i:i+nt][j]:
            res += 1
            
    ans = min(ans,res)
    
print(ans)

Solution (Python):
s=input()
t=input()
T,S=len(t),len(s)

ans=T
for i in range(S-T+1):
    tmp=[c1!=c2 for c1,c2 in zip(s[i:i+T],t)].count(True)
    ans=min(ans,tmp)
print(ans)

Solution (Python):
S = input()
T = input()
lens = len(S)
lent = len(T)
mincnt = lent
for i in range(lens - lent + 1):
  parts = S[i:i+lent]
  cnt = 0
  for j in range(lent):
    if parts[j] != T[j]:
      cnt += 1
  mincnt = min(mincnt, cnt)
print(mincnt)

Solution (Python):
S = input()
T = input()

ans = len(T)

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

print(ans)

Solution (Python):
s = input()
t = input()
x = 1001
for i in range(len(s)-len(t)+1):
  cnt = 0
  for j in range(len(t)):
    if s[j+i] != t[j]:
      cnt += 1
  x = min(x,cnt)
print (x)

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


if __name__ == "__main__":
    S = input()
    T = input()
    solve(S, T)

Solution (Python):
s = input()
t = input()

ans = float('inf')

for i in range(len(s)-len(t)+1):
    tmp_s = s[i:i+len(t)]
    tmp_ans = 0
    for j in range(len(t)):
        if tmp_s[j] != t[j]:
            tmp_ans += 1
    ans = min(ans, tmp_ans)

print (ans)

Solution (Python):
s = input()
t = input()

def num_of_match(a,b):
    l = len(a)
    return sum([a[i] == b[i] for i in range(l)])


t_len = len(t)
nom_list = []
finish_flg = False
for i in range(len(s) - len(t) + 1):
    s_sub = s[i:i + t_len]
    nom = num_of_match(s_sub, t)
    num_mod = t_len - nom
    if num_mod == 0:
        print(0)
        finish_flg = True
        break
    else:
        nom_list.append(num_mod)

if not finish_flg:
    print(min(nom_list))

Solution (Python):
s = input()
t = input()
n,m = len(s),len(t)
ans = 10**4
for i in range(n-m+1):
    c = 0
    for j in range(m):
        if t[j] != s[i+j]:
            c += 1
    ans = min(ans,c)
print(ans)

Solution (Python):
import sys
def LS2(): return list(sys.stdin.readline().rstrip())  


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

ans = 10**5
for i in range(s-t+1):
    count = 0
    for j in range(t):
        if T[j] != S[i+j]:
            count += 1
    ans = min(ans,count)

print(ans)

Solution (Python):
s = input()
t = input()
ans = 10000
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(ans)

Solution (Python):
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(ans)

Solution (Python):
s = input()
t = input()

ans = 10000

for i in range(len(s) - len(t) + 1):
    score = 0
    U = s[i:i + len(t)]
    for j in range(len(t)):
        if U[j] != t[j]:
            score += 1
    ans = min(ans, score)

print(ans)

Solution (Python):
S = input()
T = input()
len_T = len(T)

ans = 0
for i in range(len(S) -len_T+ 1):
    cnt = 0
    tmp = S[i : i + len_T]
    for j in range(len_T):
        if tmp[j] == T[j]:
            cnt += 1
    ans = max(ans, cnt)

print(len_T-ans)

Solution (Python):
s=input()
t=input()
n=len(t)
s_l=[]
for i in range(0,len(s)-n+1):
  s_l.append(s[i:i+n])


ans=100000
for si in s_l:
  tmp=sum([i!=j for i,j in zip(si,t)])
  ans=min(ans,tmp)
  
print(ans)

Solution (Python):



def main():
    s = input()
    n = len(s)
    t = input()
    m = len(t)
    ans = float('inf')

    for i in range(n - m + 1):
        u = s[i:i + m]

        count = 0

        for ui, ti in zip(u, t):
            if ui != ti:
                count += 1

        ans = min(ans, count)

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
s = list(input())
t = list(input())

value = 1000
for i in range(len(s) - len(t) + 1):
    num = 0
    for j in range(len(t)):
        if(t[j] != s[i+j]):
            num += 1
    if num < value:
        value = num
print(value)

Solution (Python):
S=input()
T=input()

Z=0
K=[]
for i in range(len(S)-len(T)+1):
    for j in range(len(T)):
        if S[j+i]!=T[j]:
            Z+=1
    K.append(Z)
    Z=0
print(min(K))

Solution (Python):
import sys

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

ls = len(S)
lt = len(T)
match = 0
for i in range(ls - lt + 1):
    tmp = 0
    for j in range(lt):
        if S[i+j] == T[j]:
            tmp += 1
    match = max(match, tmp)

print(lt - match)

Solution (Python):
S = input()
T = input()

ls = len(S)
lt = len(T)

ans = ls

for i in range(ls-lt+1):
    cnt = 0
    for j in range(lt):
        if S[i+j] != T[j]:
            cnt += 1
    ans = min(ans, cnt)
print(ans)

Solution (Python):
s, t = open(0).read().split()
n, m = len(s), len(t)
a = 2000
for i in range(n - m + 1):
    b = 0
    for j in range(m):
        b += s[i + j] != t[j]
    a = min(a, b)
print(a)

Solution (Python):
S=list(input())
T=list(input())
def ask_true(a,b):
    if a == b:
        return True
    else:
        return False
d=10000
for i in range(len(S)-len(T)+1):
    sum_=0
    for j in range(len(T)):
        if ask_true(S[i+j],T[j]):
            pass
        else:
            sum_ += 1
    d=min(sum_,d)
print(d)

Solution (Python):
S = list(input())
T = list(input())
ans = 0
for i in range(len(S)-len(T)+1):
    
    tmp_count = 0
    for j in range(len(T)):
        if S[i+j] == T[j]:
            tmp_count += 1
    ans = max(ans, tmp_count)
print(len(T)-ans)

Solution (Python):
s=input()
t=input()

an=len(t)
wk=0
for i in range(len(s)-len(t)+1):
    for j in range(len(t)):
        if s[i+j]!=t[j]:
            wk+=1
        else:
            continue
    an=min(an,wk)
    wk=0
print(an)

Solution (Python):
S = input()
T = input()
Ls = len(S)
Lt = len(T)
ans = 1000
for i in range(Ls-Lt+1):
    count = 0
    for j in range(Lt):
        if S[i+j] != T[j]:
            count += 1
    ans = min(ans, count)
print(ans)

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

Solution (Python):
S = input().strip()
N = len(S)
T = input().strip()
k = len(T)
cmin = N
for i in range(N-k+1):
    cnt = 0
    for j in range(k):
        if S[i+j]!=T[j]:
            cnt += 1
    cmin = min(cmin,cnt)
print(cmin)

Solution (Python):
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  
def LS2(): return list(sys.stdin.readline().rstrip())  


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

ans = 10**5
for i in range(s-t+1):
    count = 0
    for j in range(t):
        if T[j] != S[i+j]:
            count += 1
    ans = min(ans,count)

print(ans)

Solution (Python):
s=input()
t=input()
n = len(s)
ans = 10**9
for i in range(n):
    v = 0
    for j in range(len(t)):
        if j+i >= n: break
        if s[j+i] != t[j]: v+=1
    else:
        ans = min(ans,v)

print(ans)

Solution (Python):
S=input()
T=input()

ans = 10000

for i in range(len(S)-len(T)+1):
    count = 0

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

print(ans)

Solution (Python):
S,T = input(),input()
r = len(T)

for i in range(len(S)-len(T)+1):
    t = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            t += 1
    r = min(r,t)

print(r)

Solution (Python):
s=input()
t=input()

ans=10**9
for i in range(len(s)-len(t)+1):
    cnt=0
    for j in range(len(t)):
        if t[j]==s[i+j]:
            cnt+=1
    ans=min(ans,len(t)-cnt)
print(ans)

Solution (Python):
s = input()
t = input()

ans = 0

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 = max(ans, tmp)

print(len(t)-ans)

Solution (Python):
text = input()
target = input()


def get_diff(t1, t2):
    _diff = 0
    for pos in range(len(t1)):
        if t1[pos] != t2[pos]:
            _diff += 1
    return _diff


min_diff = len(target)
for i in range(len(text) - len(target) + 1):
    print()
    diff = get_diff(text[i:i + len(target)], target)
    min_diff = min(min_diff, diff)

print(min_diff)

Solution (Python):
s, t = input(), input()

ls = len(s)
lt= len(t)
is_double = False
c = len(s)
for i in range(ls-lt+1):
  _c = 0 
  for j in range(lt):
    if not s[i+j] == t[j]:
      _c +=1
  if c > _c:
    c = _c
    
print(c)

Solution (Python):
s = list(input())
t = list(input())

ans = 10000
for i in range(len(s)-len(t)+1):
  num = 0
  for j in range(len(t)):
    if s[i+j] != t[j]:
      num += 1
  if num < ans:
    ans = num
print(ans)

Solution (Python):
s = str(input())
t = str(input())
w = []
for i in range(len(s)-len(t)+1):
    num = 0
    for h in range(len(t)):
        if t[h] == s[i+h]:
            num += 1
    w.append(len(t)-num)
print(min(w))

Solution (Python):
s=list(input())
t=list(input())
l=[]
for i in range(len(s)-len(t)+1):
    c=0
    for j in range(len(t)):
        if s[j+i]==t[j]:
            c+=1
    l.append(c)
print(len(t)-max(l))

Solution (Python):
s = input()
t = input()

mat = 0
res = 1000

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


di = ls - lt

for i in range(di + 1):
    tag = s[i:i + lt]
    
    
    for j in range(lt):
        if t[j] != tag[j]:
            mat += 1
    if mat <= res:
        res = mat
    
    mat = 0

print(res)

Solution (Python):
s=list(input())
t=list(input())
cnt=0
total=0
big=len(t)
for i in range(0,len(s)-len(t)+1):
    for j in range(len(t)):
        if s[i]!=t[j]:
            total+=1
        i+=1
        if j==len(t)-1:
            big=min(big,total)
            total=0

print(big)

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    s = input()
    t = input()
    ans = len(t)
    for l in range(len(s)-len(t)+1):
        r = l+len(t)
        m = 0
        for i in range(len(t)):
            if t[i] != s[l+i]:
                m += 1
        if m < ans:ans = m
    print(ans)
    return


if __name__ == "__main__":
    solve()

Solution (Python):
s = input()
t = input()


def diff_count(a, b):
    c = 0
    for aa, bb in zip(a, b):
        if aa != bb:
            c += 1
    return c


min_d = len(t)

for i in range(len(s)-len(t)+1):
    ss = s[i:i + len(t)]
    d = diff_count(ss, t)
    if d < min_d:
        min_d = d

print(min_d)

Solution (Python):
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineerin College

'''
import sys
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod=1000000007

inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]



def solve():
    
    
    
    
    
    
    
    s = si()
    t = si()
    n = len(t)
    
    def f(s1):
        cnt = 0
        for i in range(n):
            if t[i]!=s1[i]:
                cnt+=1
        return cnt
        
    ans = inf
    for i in range(len(s)-n+1):
        s1 = s[i:(i+n)]
        
        ans = min(ans,f(s1))
    print(ans)
    
    
    
    
        
    
    
if __name__ =="__main__":
    
    solve()

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

Solution (Python):


s = input()
t = input()

resultdiff = len(t)




for i in range(len(s)):
  
  if len(s) < len(t) + i:
    
    break
  subs = s[i:len(t) + i]
  

  diff = 0
  for j in range(len(t)):
    if t[j] != subs[j]:
      diff += 1
  if diff < resultdiff:
    resultdiff = diff


print(resultdiff)

Solution (Python):
s = input()
t = input()

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

Solution (Python):




def main():
    S = input()
    T = input()

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

    ans = t

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

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):

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

Solution (Python):
def countdif(s, t):
  ans = 0
  for i in range(len(s)):
    if s[i] != t[i]:
      ans += 1
  return ans

s = input()
t = input()
ans = 10000
for i in range(len(s) - len(t) + 1):
  ans = min(ans, countdif(s[i:(i + len(t))], t))
  
print(ans)

Solution (Python):
s=input()
t=input()
ls=len(s)
lt=len(t)
a=[0]*(ls-lt+1)

for i in range(ls-lt+1):
    for j in range(lt):
        if s[i+j]!=t[j]:
            a[i]+=1

print(min(a))

Solution (Python):
S = list(input())
T = list(input())
ans = len(T)

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

print(ans)

Solution (Python):
S = input()
T = input()

ans = 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
  else:
    ans = max(ans, same)
    
print(len(T) - ans)

Solution (Python):
s = input()
t = input()
lt = len(t)

def dif(s, t):
    count = 0
    for i in range(lt):
        if s[i] != t[i]:
            count += 1
    return count

if t in s: print(0)
else:
    ans = float('inf')
    for i in range(len(s)-lt+1):
        ans = min(ans, dif(s[i:i+lt], t))
    print(ans)

Solution (Python):
S = input()
T = input()

ans = 0
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 = max(ans, tmp)

print(len(T) - ans)

Solution (Python):

def match1(str1, str2):
    match_count = 0
    for i in range(len(str1)):
        if str1[i] == str2[i]:
            match_count += 1

    return match_count

S = input()
T = input()

max_match = 0
for i in range(0, len(S) +1 -len(T)):
    subS = S[i:i+len(T)]
    max_match = max(max_match, match1(T, subS))
    if max_match == 0:
        for j in range(len(T)):
            if T[j] == subS[j]:
                max_match = 1

print(len(T)-max_match)

Solution (Python):
import sys


def count(substring):
  global T
  global t
  c = 0

  for i in range(t):
    if T[i] != substring[i]:
      c += 1

  return c


S = input()
T = input()

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

for i in range(s-t+ 1):
  substring = S[i:i+t]
  ans = min(ans, count(substring))

print(ans)

Solution (Python):
S = input()
T = input()
s = len(S)
t = len(T)
l1 = [] 
l2 = []
n = 0
for i in range(n, s-t+1): 
    ss = S[n:t + n]
    n += 1
    m = 0
    for x in ss:       
        if x == T[m]:
            l1.append(1)
            m +=1
        elif x != T[m]:
            l1.append(0)
            m +=1   
    l2.append(sum(l1))
    l1 = [ ]
print(t - max(l2))

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

Solution (Python):
S = input().strip()	 
T = input().strip()  

x = len(T)
ans = len(S)
for i in range(len(S) - x + 1):
  U = S[i:i+x]
  cost = sum(1 if U[k] != T[k] else 0 for k in range(x))
  ans = min(ans, cost)
print(ans)

Solution (Python):
S = input()
T = input()

min_val = len(S)
for i in range(0,len(S)-len(T)+1):
  count = 0
  for j in range(i, i+len(T)):
    if S[j] == T[j-i]:
      count += 1
  min_val = min(min_val, len(T)-count)
print(min_val)

Solution (Python):
import sys
import math


sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

S = input()
T = input()
ans = 1e9

for si in range(len(S)):
    if si+len(T) > len(S):
        break
    cnt = 0
    for i in range(len(T)):
        if S[si+i] != T[i]:
            cnt += 1
    ans = min(ans,cnt)

print(ans)

Solution (Python):
s = str(input())
t = str(input())

bestmatch = 0

for i in range(len(s) - len(t) + 1):
  match = 0
  for j in range(len(t)):
    if s[ i + j ] == t[ j ]:
      match += 1
  if match > bestmatch:
    bestmatch = match

print(len(t)-bestmatch)

Solution (Python):
S = input()
T = input()

replace_min = len(S) + 1

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

    replace_min = min(replace_min, count)

print(replace_min)

Solution (Python):
s, t = input(), input()
n, m = len(s), len(t)
print(min(sum(t[j] != s[i + j] for j in range(m)) for i in range(n - m + 1)))

Solution (Python):
S = input()
T = input()
n = len(S)
m = len(T)
x = int(1e9)
for i in range(n-m+1):
  cnt = 0
  for j in range(m):
    cnt += (S[i+j] != T[j])
  x = min(x, cnt)
print(x)

Solution (Python):
S = input()
T = input()
n = len(S)
m = len(T)
x = int(1e9)
for i in range(n-m+1):
  cnt = 0
  for j in range(m):
    cnt += (S[i+j] != T[j])
  x = min(x, cnt)
print(x)

Solution (Python):
s=list(input())
t=list(input())
S=len(s)
T=len(t)
count=0
ans=1000
for i in range(S-T+1):
  count=0
  for j in range(T):
    if s[i+j]!=t[j]:
      count+=1
  ans=min(ans,count)
print(ans)

Solution (Python):
S = input()
T = input()

best = len(S) + 100
for i in range(len(S)):
    if i + len(T) > len(S):
        break
    pair = S[i : i + len(T)]
    diffs = 0
    for a, b in zip(pair, T):
        if a != b:
            diffs += 1
    best = min(best, diffs)
print(best)

Solution (Python):
S=input()
T=input()
t = len(T)
s = len(S)
res = t
mid = 0
for i in range(s-t+1):
  mid=0
  for j in range(i,i+t):
    if S[j] == T[j-i]:
      mid += 1
  res = min(t-mid,res)
print(res)

Solution (Python):
s = input()
t = input()

ans = 10000
for i in range(len(s)-len(t)+1):
    bubun = s[i:i+len(t)]
    okikae = 0
    for j in range(len(t)):
        if bubun[j] != t[j]:
            okikae += 1
    if okikae <= ans:
        ans = okikae
print(ans)

Solution (Python):
S = input()
T = input()
max_match = 0

for s in range(0, len(S) - len(T) + 1, 1):
  tmp = 0
  for t in range(len(T)):
    if S[s+t] == T[t]:
      tmp += 1
  if max_match <= tmp:
    max_match = tmp 

print(len(T) - max_match)

Solution (Python):
S, T = input(), input()
nT = len(T)
f = lambda a, b: sum(1 for x, y in zip(a, b) if x != y)
m = 0 if S == T else nT
for i in range(len(S) - nT + 1):
    m = min(m, f(S[i:i+nT], T))
    if m == 0:
        break

print(m)

Solution (Python):
S = input()
T = input()
LS = len(S)
LT = len(T)
Range = LS-LT+1
cnt = 0
for i in range(Range):
    tmp = 0
    for j in range(LT):
        if S[i+j]==T[j]:
            tmp += 1
    cnt = max(cnt, tmp)
print(LT-cnt)

Solution (Python):
S = input()
T = input()

answer = len(T)

for i in range(0, len(S) - len(T) + 1):

    diff = 0

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

    answer = min(answer, diff)

print(answer)

Solution (Python):
s = input()
t = input()
mini =10000000

for i in range(len(s)-len(t)+1):
    count = 0
    for z in range(len(t)):
        if s[i+z] != t[z]:
            count += 1
            
    if count < mini :
            mini = count

print(mini)

Solution (Python):
S=input()
T=input()
count=0
ans1=len(S)+1
ans=0
for i in range(len(S)-len(T)+1):
    count=count+i
    for j in range(len(T)):
        if S[count]!=T[j]:
            ans+=1
        count+=1
    if ans<ans1:
        ans1=ans
    ans=0
    count=0
print(ans1)

Solution (Python):
s=input()
t=input()

res=0
for i in range(len(s)-len(t)+1):
    str_cnt=0
    for j in range(len(t)):
        if s[i+j]==t[j]:
            str_cnt+=1
    res=max(res,str_cnt)

print(len(t)-res)

Solution (Python):
s = input()
t = input()

ans = len(t)
for start in range(len(s)-len(t)+1):
  diff = 0
  for i in range(len(t)):
    if t[i] != s[start+i]:
      diff += 1
  ans = min(ans, diff)
print(ans)

Solution (Python):
s = list(input())
t = list(input())

cnt = 0
cnt_list = []

for i in range(len(s)-len(t)+1):
	for j in range(len(t)):
		if(s[i+j] != t[j]):
			cnt += 1
	cnt_list.append(cnt)
	cnt = 0


print(min(cnt_list))

Solution (Python):
def main():
    S = input()
    T = input()
    S_len = len(S)
    T_len = len(T)
    ls = []
    for i in range(S_len-T_len+1):
        ls.append(S[i:i+T_len])
    cnt_max = 0
    for can in ls:
        cnt = 0
        for i,j in zip(T,can):
            if i==j:
                cnt +=1
        if cnt_max < cnt:
            cnt_max = cnt
    print(T_len-cnt_max)
if __name__ == "__main__":
    main()

Solution (Python):
s = input()
t = input()

stri = []
mincount = -1
for i in range(len(s)-len(t)+1):
    count = 0
    for j in range(len(t)):
        if(s[i+j] == t[j]):
            count+= 1
    mincount = max(mincount,count) 
print(len(t) - mincount)

Solution (Python):
s=input();t=input();print(min([sum([x!=y for x,y in zip(s[i:],t)])for i in range(len(s)-len(t)+1)]))

Solution (Python):
def main():
    s = input()
    t = input()
    mincount = 1e9
    
    for i in range(len(s)-len(t)+1):
        count = 0
        for j in range(len(t)):
            if(s[i+j] != t[j]):
                count+= 1
        mincount = min(mincount,count) 
    print(mincount)
    return
    

if __name__ == "__main__":
    main()

Solution (Python):
s=input();t=input();n=len(s);m=len(t);print(min([sum([s[i+j]!=t[j] for j in range(m)]) for i in range(n-m+1)]))

Solution (Python):
s = input()
t = input()

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

Solution (Python):
s = input()
t = input()

stri = []
mincount = 1e9
for i in range(len(s)-len(t)+1):
    count = 0
    for j in range(len(t)):
        if(s[i+j] != t[j]):
            count+= 1
    mincount = min(mincount,count) 
print(mincount)

Solution (Python):
s = input()
t = input()

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

ans = 1000

for i in range(n-m+1):
    a = 0
    for j in range(m):
        if s[i+j] != t[j]:
            a += 1
    ans = min(ans,a)

print(ans)

Solution (Python):
from sys import stdin

s = stdin.readline().rstrip()
t = stdin.readline().rstrip()

INF  = 1005
ans = INF

for i in range(len(s) - len(t) + 1):
    newans = 0
    for j in range(len(t)):
        if s[i+j] != t[j]:
            newans += 1
    ans = min(ans, newans)

print(ans)

Solution (Python):
s = input()
t = input()

stri = []
mincount = 1e9
for i in range(len(s)-len(t)+1):
    count = 0
    for j in range(len(t)):
        if(s[i+j] != t[j]):
            count+= 1
    mincount = min(mincount,count) 
print(mincount)

Solution (Python):
s=input()
t=input()

ans=10**9+7
for i in range(len(s)-len(t)+1):
    miss=0
    tmp=s[i:i+len(t)]
    for j in range(len(t)):
        if tmp[j]!=t[j]:
            miss+=1
    ans=min(ans, miss)

print(ans)

Solution (Python):
s = input()
t = input()

def getCommonCharNum(x, y):
    commonCharNum = 0
    for i in range(len(x)):
        if x[i] == y[i]:
            commonCharNum += 1
    return commonCharNum
maxCommonNum = 0
for i in range(len(s) - len(t) + 1):
    tmpCommonCharNum = getCommonCharNum(s[i: len(t) + i], t)  
    if maxCommonNum < tmpCommonCharNum:
        maxCommonNum = tmpCommonCharNum
print(len(t) - maxCommonNum)

Solution (Python):
s = input()
t = input()
ans = len(t)
for i in range(len(s)-len(t)+1):
    cnt = 0
    for j in range(len(t)):
        if s[i+j] != t[j]:
            cnt += 1

    if ans > cnt:
        ans = cnt
print(ans)

Solution (Python):
S = input()
T = input()

len_T = len(T)
len_S = len(S)
output = len_T

for i in range(len_S-len_T+1):
    diff = 0
    for j in range(len_T):
        if T[j] != S[i+j]:
            diff += 1
    output = min(output, diff)

print(output)

Solution (Python):
s = input()
t = input()
answer = 0
for i in range(len(s) - len(t) + 1):
    w = s[i:i + len(t)]
    w_match = 0
    for w_t, w_w in zip(t, w):
        if w_t == w_w:
            w_match += 1
    answer = max(answer, w_match)
print(len(t) - answer)

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
s = S()
t = S()
ans = len(t)
for i in range(len(s) - len(t)+1):
    x = len(t)
    for j in range(len(t)):
        if s[i+j] == t[j]:
            x -= 1
    ans = min(ans, x)
print(ans)

Solution (Python):
import math
from decimal import *
import random

s1 = str(input())
s2 = str(input())
ans = int(1e9)+7
for i in range(len(s1)-len(s2)+1):
    tmp = 0
    for j in range(len(s2)):
        if(s2[j]!= s1[i+j]):
            tmp+=1
    ans = min(ans, tmp)
print(ans)

Solution (Python):
S = input()
T = input()

minCount = len(T)
for i in range(len(S)-len(T)+1):
    count = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            count += 1
    minCount = min(minCount, count)

print(minCount)

Solution (Python):
def main():
    ss = list(input())
    ts = list(input())
    n, m = len(ss), len(ts)
    ans = float("inf")
    for i in range(n-m+1):
        ans_temp = 0
        for j in range(m):
            if ss[i+j] != ts[j]:
                ans_temp += 1
        ans = min(ans, ans_temp)
    print(ans)


if __name__ == "__main__":
    main()

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


if __name__ == "__main__":
    main()