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):


import re
import math
from collections import defaultdict,deque,Counter
from fractions import Fraction
import bisect
import itertools
from itertools import accumulate
from copy import deepcopy

import heapq
import random
import time
import os
import sys
from functools import lru_cache,reduce
readline=sys.stdin.readline
sys.setrecursionlimit(100000)
alp="abcdefghijklmnopqrstuvwxyz"
numbers="0123456789"
mod=int(10**9+7)
inf=int(10**19)
class Set():
    def __init__(self,A=[]):
        self.heap=[]
        self.dic=defaultdict(bool)
        self.size=0
        for a in A:self.add(a)
    
    def __str__(self):
        return str(self.heap)
    
    def add(self,x):
        if not self.find(x):
            heapq.heappush(self.heap,x)
            self.dic[x]=True
            self.size+=1

    def remove(self,x):
        if self.find(x):
            self.dic[x]=False
            self.size-=1

    def find(self,x):
        return self.dic[x]
    
    def top(self):
        while self.heap and self.dic[self.heap[0]]==False:
            heapq.heappop(self.heap)
        if self.heap:return self.heap[0]
        else:return None

    def pop(self):
        ret=None
        if self.heap:
            ret=self.top()
            self.remove(ret)
        return ret
class multiset():
    def __init__(self,A=[]):
        self.heap=[]
        self.dic=defaultdict(int)
        self.size=0
        for a in A:self.add(a)
    
    def __str__(self):
        return str(self.heap)
    
    def add(self,x):
        heapq.heappush(self.heap,x)
        self.dic[x]+=1
        self.size+=1

    def remove(self,x):
        if self.dic[x]>0:
            self.dic[x]-=1
            self.size-=1
    
    def count(self,x):
        return self.dic[x]

    def find(self,x):
        return self.dic[x]>0
    
    def top(self):
        while self.heap and self.dic[self.heap[0]]==0:
            heapq.heappop(self.heap)
        if self.heap:return self.heap[0]
        else:return None

    def pop(self):
        ret=None
        if self.heap:
            ret=self.top()
            self.remove(ret)
        return ret
class Edge():
    def __init__(self,x,y,val=1):
        self.x=x
        self.y=y
        self.val=val
class Point():
    def __init__(self,y,x):
        self.x=x
        self.y=y
class unionfind():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(n)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):
            self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def yn(b):print("yes" if b else "no")
def Yn(b):print("Yes" if b else "No")
def YN(b):print("YES" if b else "NO")
def ispow(a,b):
    now=b
    while now<a:
        now*=b
    return now==a
def getbin(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def getfacs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def nextcomb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def getprimes(n):
    if n==0:return []
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    ret=[]
    for a in range(n+1):
        if(A[a]):ret.append(a)
    return ret
def isprime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(b,t,f):return t if b else f
def factorize(n):
    b = 2
    ret=defaultdict(int)
    while b * b <= n:
        while n % b == 0:
            n //= b
            ret[b]+=1
        b+=1
    if n > 1:ret[n]+=1
    return ret
def inputintlist(row=1): 
    if row==1:
        ret=list(map(int,input().split()))
    else:
        ret=[None]*row
        for a in range(row):
            ret[a]=int(input())
    return ret
def inputfloatlist(row=1): 
    if row==1:
        ret=list(map(float,input().split()))
    else:
        ret=[None]*row
        for a in range(row):
            ret[a]=float(input())
    return ret
def istanchouzouka(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>=a:
            f=False
        prev=a
    return f
def istanchouhigensyou(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>a:
            f=False
        prev=a
    return f
def getallsum(A):
    s=sum(A)
    dp=defaultdict(int)
    dp[0]=1
    for a in range(0,len(A)):
        for b in range(s,-1,-1):
            if b-A[a]>=0:
                dp[b]+=dp[b-A[a]]
    return dp
def yuukoutomukou(edges):
    ret=deepcopy(edges)
    for edge in edges:
        if not edge.x==edge.y:
            ret.append(Edge(edge.y,edge.x,edge.val))
    return ret
def dijkstra(edges,V,start):
    from queue import PriorityQueue
    mincost=[inf]*V
    G=[[] for a in range(V)]
    for edge in edges:
        G[edge.x].append([edge.val,edge.y])
    Q=PriorityQueue()
    Q.put([0,start])
    while not Q.empty():
        nowcost,nowx=Q.get()
        if mincost[nowx]==inf:
            mincost[nowx]=nowcost
            for cost,y in G[nowx]:
                newcost=nowcost+cost
                Q.put([newcost,y])
    return mincost
def warshallfloyd(edges,V):
    mincost=[[inf for b in range(V)] for a in range(V)]
    for a in range(V):mincost[a][a]=0
    for edge in edges:
        mincost[edge.x][edge.y]=min(mincost[edge.x][edge.y],edge.val)
    for k in range(V):
        for s in range(V):
            for t in range(V):
                if mincost[s][k]==inf or mincost[k][t]==inf:continue
                mincost[s][t]=min(mincost[s][t],mincost[s][k]+mincost[k][t])
    return mincost
def bellemanford(edges,V,start):
    mincost=[inf]*V
    mincost[start]=0
    for _ in range(V):
        for edge in edges:
            if mincost[edge.x]==inf:continue
            mincost[edge.y]=min(mincost[edge.y],mincost[edge.x]+edge.val)
    return mincost
def getmd(x1,y1,x2,y2):return abs(x1-x2)+abs(y1-y2)
def geted(x1,y1,x2,y2):return math.sqrt((x1-x2)**2+(y1-y2)**2)
class fordfulkerson():
    def __init__(self,edges,V,s,t):
        self.V=V
        self.used=[False]*V
        self.G=[[] for a in range(V)]
        self.s=s
        self.t=t
        for edge in edges:
            self.G[edge.x].append({"x":edge.x,"y":edge.y,"cap":edge.val,"rev":len(self.G[edge.y])})
            self.G[edge.y].append({"x":edge.y,"y":edge.x,"cap":0,"rev":len(self.G[edge.x])-1})
    def dfs(self,v,t,f=inf):
        if v==t:return f
        self.used[v]=True
        for a in range(len(self.G[v])):
            x=self.G[v][a]["x"]
            y=self.G[v][a]["y"]
            cap=self.G[v][a]["cap"]
            rev=self.G[y][self.G[x][a]["rev"]]
            if self.used[y] or cap==0:continue
            f2=self.dfs(y,t,min(f,cap))
            if f2>0:
                self.G[v][a]["cap"]-=f2
                rev["cap"]+=f2
                return f2
        return 0
    def maxflow(self):
        flow=0
        while True:
            self.used=[False]*V
            zouka=self.dfs(self.s,self.t)
            if zouka==0:break
            flow+=zouka
        return flow
def zipsort(*args):
    ziplist=sorted(zip(*args))
    for a in range(len(args)):
        for b in range(len(ziplist)):
            args[a][b]=ziplist[b][a]
def zipreverse(*args):
    ziplist=list(zip(*args))
    rev=[]
    for a in range(len(ziplist)-1,-1,-1):
        rev.append(ziplist[a])
    for a in range(len(args)):
        for b in range(len(rev)):
            args[a][b]=rev[b][a]

def to10(A):
    ret=0
    for a in range(len(A)-1,-1,-1):
        ret+=X[a]*2**(N-1-a)
    return ret

S=input()
T=input()
mmin=inf
for a in range(len(S)-len(T)+1):
    s=""
    for b in range(a,a+len(T)):
        s+=S[b]
    cnt=0
    for b in range(len(T)):
        if T[b]!=s[b]:cnt+=1
    mmin=min(mmin,cnt)
print(mmin)

Solution (Python):
def main():
    s = input()
    t = input()
    s_len, t_len = len(s), len(t)

    def gen():
        for left in range(0, s_len - t_len + 1):
            edit = sum((c_s != c_t) for c_s, c_t in zip(s[left:], t))
            yield edit
    return min(gen())


if __name__ == '__main__':
    print(main())

Solution (Python):
import math

S = input()
T = input()
ans = math.inf
for i in range(len(S) - len(T)+1):
    tmp = sum([s != t for s, t in zip(S[i:i + len(T)], T)])
    ans = min(ans, tmp)
print(ans)

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

n = len(s) - len(t) + 1
m = [0] * n

for i in range(n):
    for j in range(len(t)):
        if s[i + j] != t[j]:
            m[i] += 1

print(min(m))

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

LT = len(T)
same = 0
if len(S) - LT != 0:
    for i in range(len(S) - LT):
        tS = S[i:i+LT]
        tmp = 0
        for j in range(LT):
            if T[j] == tS[j]:
                tmp += 1
        same = max(same,tmp)
    print(LT - same)
else:
    ans = 0
    for i in range(LT):
        if T[i] == S[i]:
            ans += 1
    print(LT - ans)

Solution (Python):
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


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

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


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

INF=10**9
ans=INF
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()
c=len(T)
for i in range(len(S)-len(T)+1):
  d=0
  for j in range(len(T)):
    if S[i+j]!=T[j]:
      d+=1
  if d<c:
    c=d
print(c)

Solution (Python):
s = input()
t = input()
l = len(s) - len(t)
lt = int(len(t))
count = 0
max_count = 100000000000
for i in range(l+1):
  x = s[i:lt+i]
  for i in range(len(x)):
    if x[i] != t[i]:
      count += 1
  if count <= max_count:
    max_count = count
  count = 0
print(max_count)

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

tt = t

max_count = 0
while True:
    count = 0
    for i in range(len(tt)):
        if s[i] == tt[i]:
            count += 1 
    
    max_count = max(max_count, count)
    
    
    if len(s) == len(tt):
        break
    
    tt = ' ' + tt
    
print(len(t) - max_count)

Solution (Python):
S = input()
T = input()
ans = 10000
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 = list(input())
t = list(input())
ss, tt = len(s), len(t)
flag = 0
for i in range(ss - tt + 1):
    temp = s[i: i + tt + 1]
    ttt = 0
    for k, j in zip(temp, t):
        if k == j:
            ttt += 1
    flag = max(flag, ttt)
print(tt - flag)

Solution (Python):
import sys,math
from collections import deque,defaultdict
import operator as op
from functools import reduce

sys.setrecursionlimit(10**6) 

I=sys.stdin.readline

 

"""
x_move=[-1,0,1,0,-1,1,1,-1]
y_move=[0,1,0,-1,1,1,-1,-1]
"""
def ii():
	return int(I().strip())
def li():
	return list(map(int,I().strip().split()))
def mi():
	return map(int,I().strip().split())

def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer // denom

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x




	
def main():
	s=I().strip()
	t=I().strip()
	win=len(t)
	ans=999999
	for i in range(len(s)-win+1):
		x=0
		for j in range(win):
			if s[i+j]!=t[j]:
				x+=1
		ans=min(ans,x)
	print(ans)

			


	

























	
	
	





if __name__ == '__main__':
	main()

Solution (Python):

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

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

anslist=[]

for i in range(ls-lt+1):
    ans=lt
    S_list=S[i:i+lt]
    for j in range(lt):
        if S_list[j]==T[j]:
            ans-=1
    anslist.append(ans)

print(min(anslist))

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

ns= len(s)
nt = len(t)
ans =0


for i in range(ns-nt+1):
    count = 0
    for j in range(nt):
        if s[i+j] == t[j]:
            count +=1
    else:
        ans = max(ans, count)

print(nt-ans)

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

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

a = []
for i in range(len(s)-len(t)+1):
  count = 0
  for j in range(len(t)):
    if t[j] != s[j+i]:
      count += 1
  a.append(count)
  
print(min(a))

Solution (Python):
def main():
    S = str(input())
    T = str(input())

    max = 0
    for i in range(len(S)-len(T)+1):
        count = 0
        for n in range(len(T)):
            if S[i+n] == T[n]:
                count += 1
        if count > max:
            max = count
    print(len(T) - max)


main()

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

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

    ans = min(ans, tmp)

print(ans)

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

def solve(S,T):
    m = 1000000
    
    for i in range(len(S)-len(T)+1):
        cnt = difference(T,S[i:i+len(T)])

        m = min(m,cnt)

    return m


def difference(a,b):
    c = 0
    for i in range(len(a)):
        if a[i] != b[i]:
            c+=1

    return c

print(solve(S,T))

Solution (Python):





"""
"""

from collections import defaultdict
import bisect

import sys
input = sys.stdin.readline

def solve(s,t):
    l = len(t)
    flags = [True]+[False]*3
    tmp = 0
    for i in range(len(s)-l+1):
        tmp2 = 0
        for j in range(l):
            if s[i+j] == t[j]:
                tmp2 += 1
        tmp = max(tmp,tmp2)
    print(l-tmp)

            

def main():
    s = input().rstrip()
    t = input().rstrip()
    solve(s,t)


if __name__ == "__main__":
    main()

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

ans = float("INF")
for i in range(len(s)-len(t)+1):
    x = 0
    for j in range(len(t)):
        x += (s[i+j] != t[j])
    ans = min(ans,x)
print(ans)

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

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

    if cnt > m_cnt:
        m_cnt = cnt
    cnt = 0

print(len(T) - m_cnt)

Solution (Python):
import math
import collections
import itertools

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

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

resolve()

Solution (Python):
S = list(input())
N = len(S)
T = list(input())
n = len(T)
ans = n
for i in range(N - n + 1):
    s = S[i:i + n]
    a = 0
    for j in range(n):
        if T[j] != s[j]:
            a += 1
    if a < ans:
        ans = a
print(ans)

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

for i in range(len(s) - len(t) + 1):
    cor = 0
    for j in range(len(t)):
        if t[j] != s[i + j]:
            cor = cor + 1
    if min_cor > cor:
        min_cor = cor
print(min_cor)

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

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

print(len(T)-max_count)

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


vals = []
for i in range(0, len(s) - len(t) + 1):
    q = s[i:i + len(t)]
    

    cnt = 0
    for j in range(len(t)):
        
        
        if q[j] != t[j]:
            cnt += 1
        

        

    vals.append(cnt)
    
print(min(vals))

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

min_ = 99999
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 < min_:
        min_ = count
print(min_)

Solution (Python):
s = input()
t = input()
maxCnt = 0
len_s = len(s)
len_t = len(t)
for i in range(len_s - len_t + 1):
    cnt = 0 
    s_str = s[i:i+len_t]
    for j in range(len(t)):
        if t[j] == s_str[j]:
            cnt += 1
        else:
            pass
    maxCnt = max(maxCnt, cnt)
ans = len_t - maxCnt
print(ans)

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

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

d = len(s) - len(t)
min_c = int(1e4)
for i in range(d+1):
    st = s[i:i+len(t)]
    c = 0
    for j in range(len(t)):
        if st[j] != t[j]:
            c += 1
            if c > min_c:
                break
    min_c = min(c, min_c)

print(min_c)

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

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

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

Solution (Python):
def matching(a,b):
    count=0
    for i in range(len(a)):
        if a[i]==b[i]:
            count+=1
    return len(a)-count

s=input()
t=input()
k=len(s)
l=len(t)
minChange=None
for i in range(k-l+1):
    temp=s[i:i+l]
    change=matching(temp,t)
    if minChange==None or change<minChange:
        minChange=change
print(minChange)

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

lenS = len(S)
lenT = len(T)

ans = lenT
for i in range(lenS - lenT + 1):
    mem = 0
    for j, t in enumerate(T):
        if S[i + j] != t:
            mem += 1
    ans = min(ans, mem)
print(ans)

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

d = len(S)-len(T)

cntlist = []
for i in range(d+1):
    cnt = 0
    s = S[i:i+len(T)]
    for j in range(len(T)):
        cnt += T[j] == s[j]
    cntlist.append(cnt)

print(len(T)-max(cntlist))

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

ham_dist = []
for i in range(0, len(s)-len(t)+1):
    dist = 0
    for j in range(len(t)):
        if s[i+j] != t[j]:
            dist += 1
    ham_dist.append(dist)
print(min(ham_dist))

Solution (Python):
s = input()
t = input()
lens, lent = len(s), len(t)
n = lens - lent + 1
mi = lent
for i in range(n):
    temp = 0
    for j in range(lent):
        if s[i + j] != t[j]:
            temp += 1
    if temp <= mi:
        mi = temp
print(mi)

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

def func(s, t):
    x = len(t)
    for i in range(len(t)):
        if s[i]==t[i]:
            x-=1
    return x
ans = 10000
for j in range(len(S)-len(T)+1):
    s = S[j:j+len(T)]
    ans = min(ans, func(s,T))
print(ans)

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

s=len(S)
t=len(T)
s_end=s-t+1

def count_mismatch(a):
    global t
    global T

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


ans = t
for i in range(s_end):
    c = count_mismatch(S[i:i+t])
    if c < ans:
        ans = c

print(ans)

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

def compare(a,b):
    r = 0
    for i in range(len(a)):
        if a[i] != b[i]:
            r += 1
    return r

res = 10000
for i in range(len(s)-len(t)+1):
    res = min(compare(s[i:i+len(t)], t), res)

print(res)

Solution (Python):
S = list(input())
T = list(input())
len_s = len(S)
len_t = len(T)

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

print(len_t - max_same)

Solution (Python):
x = input()
y = input()

re = 0

for a in range(0,len(x)-len(y)+1):
  z = 0
  for b in range(0,len(y)):
    if y[b] == x[b+a]:
      z = z+1
      if(z>re):
        re = z
dd = len(y) - re
print(dd)

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

len_s = len(S)
len_t = len(T)

max_count = 0
for x in range(len_s - len_t + 1):
    count = 0 
    for y in range(len_t):

        if S[y+x] == T[y]:
            count += 1
        else:
            pass


    if max_count < count:
        max_count = count

    
print(len_t - max_count)

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

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

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

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

min_count = t
for i in range(s - t + 1):
    count = 0
    for j, tt in enumerate(T):
        if S[i: i + t][j] == tt:
            count += 1
    change = t - count
    if change < min_count:
        min_count = change
print(min_count)

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

print(ans)

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

max_val = 0
index = 0
for i in range(len(s)- len(t) + 1):
    val = 0
    for c in range(len(t)):
        if s[i + c] == t[c]:
            val += 1
            if val > max_val:
                max_val = val
                index = [i]

print(len(t) - max_val)

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

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

Solution (Python):
s = list(map(str,input()))
t = list(map(str,input()))

same = 0

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

print(max(0,len(t) - same))

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

Solution (Python):
s = input()
t = input()
res = float('inf')
ls, lt = len(s), len(t)
for i in range(ls - lt + 1):
    f = 0
    for j in range(lt):
        if t[j] != s[i + j]:
            f += 1
    res = min(f, res)
print(res)

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

ans = 0
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 = max(count, ans)
print(len(t)-ans)

Solution (Python):
s = input()
t = input()
cnt_max = 0
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 cnt > cnt_max:
        cnt_max = cnt
print(len(t)-cnt_max)

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

t = str(input())

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

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

print(c)

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

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

Solution (Python):
s=input()
t=input()
import sys
a=0
b=[]
c=[]
if len(s)==len(t):
    for i in range(len(s)):
        if s[i]!=t[i]:
            a+=1
    print(a)
    sys.exit()
for i in range(len(s)-len(t)):
    b.append(s[i:len(t)+i])


for i in range(len(b)):
    for j in range(len(b[i])):
        if b[i][j]!=t[j]:
            a+=1
    c.append(a)
    a=0
        
print(min(c))

Solution (Python):

S =input()
T =input()

match_list = [0]*len(S)

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

print(len(T) - max(match_list))

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

Solution (Python):
s=input()
t=input()
num=len(s)-len(t)
res=[]
for n1 in range(0,num+1):
    count=0
    for n2 in range(0,len(t)):
        if(t[n2]!=s[n1+n2]):
            count+=1
    res.append(count)
print(min(res))

Solution (Python):


import sys


S = input()
T = input()




def get_match_count(s1: str, s2: str) -> int:
    match_count = 0
    for c1, c2 in zip(s1, s2):
        if c1 == c2:
            match_count += 1
    return match_count


N = len(S)
M = len(T)
ans = sys.maxsize
for i in range(N - M + 1):
    ans = min(ans, M - get_match_count(S[i:i + M], T))


print(ans)

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

ans=1000

for i in range(len(s)):
    x=0
    if i+len(t)<=len(s):
        for j in range(len(t)):
            if s[i+j]!=t[j]:
                x+=1
        if x<ans:
            ans=x
    else:
        break
print(ans)

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

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

print(lenT - ansA)

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

t = T
cnt = len(T)

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

for i in range(N-M+1):
    check = S[i:i+M]
    ck = 0
    for j in range(M):
        if check[j] != T[j]:
            ck += 1
    if ck < cnt:
        cnt = ck

print(cnt)

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

Solution (Python):
s = input()
t = input()
ns = len(s)
nt = len(t)
ret = ns + 1
for i in range(ns - nt+ 1):
  tmp = 0
  for j in range(nt):
    if s[i + j] != t[j]:
      tmp += 1
  if ret > tmp:
    ret = tmp
    
print(ret)

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

print(min)

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

l = len(T)

def diff(s):
	return sum([s[i] != T[i] for i in range(l)])

print(min([diff(S[i:i + l]) for i in range(len(S) - l + 1)]))

Solution (Python):

from functools import reduce
from queue import Queue
from collections import deque

s = input()
t = input()

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

print(saisho_kyori)

Solution (Python):
from itertools import combinations
import math
S = input()
T = input()






c = 0
for i in range(len(S)-(len(T)-1)):
    cc = 0
    for t in range(i, i+len(T)):
        if S[t] == T[t-i]:
            cc += 1
    if c<cc:
        c=cc
print(len(T)-c)

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

s = list(s)
s.append("0")
t = list(t)
roop = len(s)-len(t)
cc = []
for i in range(roop):
  c = 0
  tmp = []
  tmp = s[i:len(t)+1+i]
  for i in range(len(t)):
    if tmp[i] == t[i]:
      c += 1
  cc.append(c)

ma = max(cc)
a = cc.index(ma)
tmp = s[a:a+1+len(t)]
ans = 0

for i in range(len(t)):
  if tmp[i] != t[i]:
    ans += 1
print(ans)

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

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

count = 0
ans = 0

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

print(len(t) - ans)

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

Solution (Python):
S=input()
T=input()
A=[]
for i in range(len(S)-len(T)+1):
    s=S[i:i+len(T)]
    t=[T[j] for j in range(len(T)) if s[j] != T[j]]
    A.append(len(t))
print(min(A))