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



Sample input:
cabacc
abc


Sample output:
1

Submission status: Accepted

Solution code:
s = input()
t = input()
ls = len(s)
lt = len(t)

ans = 0
for i in range(ls-lt+1):
  same = 0
  for j in range(lt):
    ind = i+j
    if s[ind]==t[j]:
      same += 1
  ans = max(ans,same)
print(lt-ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
lS = len(S)
lT = len(T)
C = []
for i in range(lS-lT+1):
    count = 0
    for j in range(lT):
        if S[i+j]!=T[j]:
            count += 1
    C.append(count)
print(min(C))

Submission status: Accepted

Solution code:
S = input()
T = input()
t_len = len(T)
count = len(S) - len(T) + 1
max_correct = []
for i in range(count):
  s_tmp = S[i:t_len]
  correct = 0
  for n, s in enumerate(s_tmp):
    if s == T[n]:
      correct += 1
  max_correct.append(correct)
  
  i = i + 1
  t_len = t_len + 1

max_correct = len(T) - max(max_correct)
print(max_correct)

Submission status: Accepted

Solution code:
"""B."""

import sys

input = sys.stdin.readline  # noqa: A001

S = input()[:-1]
T = input()[:-1]

S_L = len(S)
T_L = len(T)
ans = T_L

for i in range(S_L - T_L + 1):
    S_2 = S[i:i + T_L]
    match = 0
    for v1, v2 in zip(S_2, T):
        match += bool(v1 != v2)
    ans = min(ans, match)

print(ans)

exit(0)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
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 T[j] != S[i:i+len(T)][j]:
            cnt += 1
    ans = min(ans, cnt)

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

def diff(s1, s2):
    d = len(s1)

    d -= len([i for i,j in zip(s1, s2) if i == j])
    return d

dlen = min([diff(T, S[i:i+lt]) for i in range(ls) if i + lt <= ls])

print(dlen)

Submission status: Accepted

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

# S = "cabacc"
# T = "abc"

lt = len(T)

def diff(s1, s2):
    d = len(s1)

    d -= len([i for i,j in zip(s1, s2) if i == j])
    return d

dlen = 1000000000
for i in range(len(S)):
    if i + lt <= len(S):
        dlen = min(dlen, diff(T, S[i:i+lt]))

print(dlen)

Submission status: Accepted

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

n = len(s) - len(t)
l = len(t)

res = 0
for i in range(n+1):
    cnt = 0
    for j in range(l):
        if s[i+j] == t[j]:
            cnt += 1
    res = max(res, cnt)

print(l - res)

Submission status: Accepted

Solution code:
S = input()
T = input()
largest = 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
    if largest < count:
        largest = count
print(len(T) - largest)

Submission status: Accepted

Solution code:
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math
import random
J=10**19
###############################################################################\n=17
s=input()
t=input()
ans=10**6
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(count,ans)
print(ans)

Submission status: Accepted

Solution code:
import sys
import itertools
sys.setrecursionlimit(10000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

if __name__ == "__main__":
    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 s[i+j] != t[j]:
                cnt+=1
        ans = min(ans,cnt)
    print(ans)

Submission status: Accepted

Solution code:
def main() :

    s = input()
    t = input()

    if (t in s) :
        print(0)
        return
    
    difference = 99999999
    for offset in range(0,len(s) - len(t)+1):
        s2 = s[offset:offset+len(t)]
        diff = 0
        for i in range(len(t)) :
            if (s2[i] != t[i]) :
                diff += 1
        
        if (difference > diff) :
            difference = diff
    
    print(difference)

main()

Submission status: Accepted

Solution code:
S = input()
T = input()
U = [0] * (len(S)-len(T)+1)
for j in range(len(S)-len(T)+1):
    for i in range(len(T)):
        if(S[i+j] != T[i]):
            U[j] += 1
print(min(U))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
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[i + j]:
            count += 1
    a.append(count)
print(len(t)-max(a))

Submission status: Accepted

Solution code:
str1 = list(input())
str2 = list(input())

answer = len(str2)
for i in range(len(str1)-len(str2)+1):
    count = 0

    for j in range(len(str2)):
        if not str1[i+j] == str2[j]:
            count += 1

    if count < answer:
        answer = count

print(answer)

Submission status: Accepted

Solution code:
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

s = input()
t = input()

a = []
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
    a.append(cnt)
print(len(t) - max(a))

Submission status: Accepted

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

maxx = 0

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

print(len(t) - maxx)

Submission status: Accepted

Solution code:
S, T = input(), input()
ans = 2**10
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)

Submission status: Accepted

Solution code:
long_str = input()
short_str = input()
short_list = list(short_str)

long_len = len(long_str)
short_len = len(short_str)
iter_num = long_len - short_len + 1

max_count = 0
for i in range(iter_num):
  tmp = 0
  obj_list = list(long_str[i:(short_len+i)])
  for s, o in zip(short_list, obj_list):
    tmp += int(s == o)
  max_count = max(max_count, tmp)

print(short_len - max_count)

Submission status: Accepted

Solution code:
s = input()
t = input()
c = 0
ctemp = 0 

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

Submission status: Accepted

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

ans = len(t)
long = ans

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

print(ans)

Submission status: Accepted

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


max = 0

for offset in range(len(s)-len(t)+1):
    cnt = 0
    for i in range(len(t)):
        if t[i] == s[offset+i]:
            cnt += 1
    if cnt > max:
        max = cnt

print(len(t)-max)

Submission status: Accepted

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

ans = float('INF')
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(ans, diff)
print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
minimam = 10000

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
    minimam = min(minimam, count)


print(minimam)

Submission status: Accepted

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

ans = 1000000  # 適当に1001以上を初期値にしておきます

# Tが1文字のときlen(S)回、2文字のときlen(S) - 1回 …… なので、
# len(S) - len(T) + 1 回です
for i in range(len(S) - len(T) + 1):
    score = 0
    U = S[i:i + len(T)]  # Sのi文字目から連続するlen(T)文字を、Uとします
    for j in range(len(T)):
        if U[j] != T[j]:
            score += 1
    ans = min(ans, score)

print(ans)

Submission status: Accepted

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

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

ans = float("inf")
for i in range(n-m+1):
  p = m
  for j in range(m):
    if s[i+j] == t[j]: p -= 1
  if p < ans: ans = p
print(ans)

Submission status: Accepted

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


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

print(ans)

Submission status: Accepted

Solution code:
S = str(input())
T = str(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(cnt, ans)

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python

def count(a, b):
    ans = 0
    for i, j in zip(a, b):
        if i != j:
            ans += 1
    return ans

s = input()
t = input()

ans = len(s)

for i in range(0, len(s)-len(t)+1):
    a = s[i:i+len(t)+1]
    ans = min(ans, count(a, t))

print(ans)

Submission status: Accepted

Solution code:
s=input()
t=input()
ans=len(t)
for i in range(len(s)):
  if i+len(t)>len(s):break
  anss=0
  for j in range(len(t)):
    if t[j]!=s[i+j]:anss+=1
  ans=min(ans,anss)
print(ans)

Submission status: Accepted

Solution code:
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

s = ins()
t = ins()
ls = len(s)
lt = len(t)
mn = BIG
for i in range(ls-lt+1):
    x = 0
    for j in range(lt):
        if s[i+j]!=t[j]:
            x += 1
    mn = min(mn,x)
print(mn)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S = input()
T = input()
 
Nmax = 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
 
    Nmax = min(diff, Nmax)
 
print(Nmax)

Submission status: Accepted

Solution code:
s = input()
t = input()
if s.count(t):
    print(0)
else:
    len_t = len(t)
    cnt = 0
    for i in range(len(s) - len_t + 1):
        c = 0
        for j in range(len_t):
            if s[i+j] == t[j]: c += 1
        cnt = max(cnt, c)
    print(len_t - cnt)

Submission status: Accepted

Solution code:
s = input()
t = input()
sl = len(s)
tl = len(t)
ans = 1001

for i in range(sl-tl+1):
    cnt = 0
    for sv, tv in zip(s[i:i+tl], t):
        if sv != tv:
            cnt += 1
    ans = min(cnt, ans)

print(ans)

Submission status: Accepted

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

Nmax = 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

    Nmax = min(diff, Nmax)

print(Nmax)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
t=input()
ans=len(t)
cnt=0

for _ in range(len(s)):
  if _+len(t)>len(s):
    break
  mj=s[_:_+len(t)]
  for i in range(len(t)):
    if mj[i]!=t[i]:
      cnt += 1
  if ans>cnt:
    ans=cnt
  cnt=0
    
print(ans)

Submission status: Accepted

Solution code:
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(ans, diff)

print(ans)

Submission status: Accepted

Solution code:
def main():
    a = [input() for i in range(2)]
    S = a[0]
    T = a[1]
    count = 1001
    # 網羅的に一致しない文字数をカウント
    for i in range(len(S) - len(T) + 1):
        count_temp = 0
        for j in range(len(T)):
            if S[i + j] != T[j]:
                count_temp += 1
        count = min(count, count_temp)
        if count == 0:
            break
    print(count)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
t = input()
ans = 1001001001
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 <= ans:
        ans = cnt
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
T=input()
s=len(S)
t=len(T)
A=[]


for i in range(s-t+1):
  word=S[i:i+t]
  a=0
  for j in range(t):
    if word[j]==T[j]:
      a+=1
    else:
      a+=0
  A.append(t-a)

print(min(A))

Submission status: Accepted

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

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

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

print(x)

Submission status: Accepted

Solution code:
S = str(input())
T = str(input())
lenS = len(S)
lenT = len(T)
max_match = 0
for idx in range(lenS - lenT + 1):
    cnt_match = 0
    for i in range(lenT):
        if S[idx + i] == T[i]:
            cnt_match += 1
    if cnt_match > max_match:
        max_match = cnt_match
print(lenT - max_match)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S = input()
T = input()
 
def match_num_character(x, y):
  count = 0
  for a, b in zip(x, y):
    if a == b:
      count += 1
      
  return count
 
length = len(T)
max_count = max([match_num_character(S[i:i+length], T) for i in range(1+len(S) - length)])
 
print(length - max_count)

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
result=0
#count=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
        #s[i:i+len(t)] == t
    
    if count>result:
        result=count


print(len(t)-result)

Submission status: Accepted

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

ans = 1000

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
    if ans > diff:
        ans = diff

print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
ans = len(t)
for i in range(len(s)-len(t)+1):
  # i は開始位置
  curr = 0
  for j in range(len(t)):
    if s[i+j] != t[j]:
      curr+=1
  ans = min(curr, ans)
  
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
t = input()
a = len(s)
b = len(t)
ans = 2000
for i in range(a-b+1):
  k = 0
  for j in range(b):
    if s[i+j] != t[j]:
      k += 1
  ans = min(ans,k)
print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
ans = float('inf')

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

print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
min_change = 10**9
for posi_1 in range(len(S)-len(T)+1):
  tmp = 0
  for posi_2 in range(len(T)):
    if S[posi_1+posi_2] != T[posi_2]:
      tmp += 1
  min_change = min(tmp, min_change)
print(min_change)

Submission status: Accepted

Solution code:
# coding: utf-8
# 自分の得意な言語で
# Let's チャレンジ！！

a = input()
b = input()

s = 1001

for i in range(len(a) - len(b)+ 1):
    score = 0
    test = a[i:i+len(b)]
    for j in range(len(b)):
        if test[j] != b[j]:
            score += 1
    s = min(s, score)

print(s)

Submission status: Accepted

Solution code:
# import math
# import statistics
a=input()
b=input()
#b,c=int(input()),int(input())
c,d=[],[]
for i in a:
    c.append(i)
for i in b:
    d.append(i)
#e1,e2 = map(int,input().split())
# f = list(map(int,input().split()))
#g = [input() for _ in range(a)]
# h = []
# for i in range(e1):
#     h.append(list(map(int,input().split())))
ma=[]
if b in a:
    print(0)
else:
    for i in range(len(c)-len(d)+1):
        count=0
        for k in range(len(d)):
            if c[i:len(d)+i][k]!=d[k]:
                count+=1
        ma.append(count)
    print(min(ma))

Submission status: Accepted

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

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

print(len(t)-ans)

Submission status: Accepted

Solution code:
s=input()
t=input()
L=len(s)
l=len(t)
X=[]
for i in range(L-l+1):
    x=0
    for j in range(l):
        if s[i+j]!=t[j]:
            x+=1
    X.append(x)
print(min(X))

Submission status: Accepted

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

ans = []
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.append(count) 

print(min(ans))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
s = input()
t = input()
ls = len(s)
lt = len(t)
ans = 1000  # min
for i in range(ls - lt + 1):
    tmp_cnt = 0
    for j in range(lt):
        if s[i + j] != t[j]:
            tmp_cnt += 1
    ans = min(ans, tmp_cnt)
print(ans)

Submission status: Accepted

Solution code:
S=list(input())
T=list(input())
A=[]
for i in range(len(S)-len(T)+1):
    B=0
    for j in range(len(T)):
        if T[j]==S[i+j]:
            continue
        else:
            B =B+1
    A.append(B)

A.sort()
print(A[0])

Submission status: Accepted

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

Submission status: Accepted

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

min = 1000
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:
            break
    if count < min:
        min = count

print(min)

Submission status: Accepted

Solution code:
s = input()
t = input()
c = 0

for i in range(len(s) - len(t) + 1):
    c_1 = 0
    for j in range(len(t)):
        if s[i + j] == t[j]:
            c_1 += 1
    if c < c_1:
        c = c_1

print(len(t) - c)

Submission status: Accepted

Solution code:
from sys import stdin
def ip(): return [int(i) for i in stdin.readline().split()]
def sp(): return [str(i) for i in stdin.readline().split()]


s = str(input())
t = str(input())

ans = len(t)
for i in range(len(s) - len(t) + 1):
    # print(f'{i=} | {ans=}')
    curr = len(t)
    for j in range(i, len(t) + i):
        # print(f'{curr=} | {s[j]=} | {t[j-i]=}')
        if s[j] == t[j-i]:
            curr -= 1
    ans = min(ans, curr)
print(ans)

Submission status: Accepted

Solution code:

S, T = [input() for x in range(2)]
lenT = len(T)
max_match_len = 0

for i in range(len(S)-lenT+1):
  compareS = S[i:i+lenT]
  match_len = 0
  for j in range(lenT):
    if compareS[j] == T[j]:
      match_len += 1
  else:
    if max_match_len < match_len:
      max_match_len = match_len
print(lenT - max_match_len)

Submission status: Accepted

Solution code:

S = input()
T = input()

count = 0
max_count = 0

for i in range(len(S) - len(T) +1):
    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)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
S = input()
T = input()

ans = len(T)

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

    ans = min(ans, diff)

print(ans)

Submission status: Accepted

Solution code:
S, T = [input() for x in range(2)]
max_match_len = 0

for i in range(len(S)):
  if len(S) - len(T) < i:
    break
  compare_s = S[i:i+len(T)]
  match_len = 0
  for j in range(len(T)):
    if compare_s[j] == T[j]:
      match_len += 1
  else:
    if max_match_len < match_len:
      max_match_len = match_len
print(len(T) - max_match_len)

Submission status: Accepted

Solution code:
list_data = [input() for _ in range(2)]

s = list_data[0]
t = list_data[1]

len_t = len(t)

max_correct = 0
for i in range(len(s)-len(t)+1):
  correct = 0
  for j in range(len(t)):
    if s[i+j] == t[j]:
      correct += 1
  
  if max_correct < correct:
    max_correct = correct

print(len_t - max_correct)

Submission status: Accepted

Solution code:
from sys import stdin

S = input()
T = input()

ans  =10000
# 全探索を実施
for i in range(len(S) - len(T) + 1):
    # 不一致だった文字数
    mat = 0
    # i番目からTの長さ分の文字列が入る
    U = S[i:i + len(T)]
    for j in range(len(T)):
        # 一文字ずつアンマッチかを確認する
        if U[j] != T[j]:
            mat += 1
    # 小さいほうが入る
    ans = min(ans, mat)

print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
ans = len(t)
c = 0
for i in range(len(s)-len(t)+1):
  c = 0
  for j in range(len(t)):
    if s[i+j] != t[j]:
      c += 1
  if ans > c:
    ans = c
print(ans)

Submission status: Accepted

Solution code:
str = input()
text = input()
ans = len(text)
for i in range(len(str) - len(text) + 1):
    dif = 0
    for j in range(len(text)):
        if not str[i+j] == text[j]:
            dif += 1
    ans = min(ans, dif)
print(ans)

Submission status: Accepted

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

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

result = len_t
i = 0

while (i <= len_s - len_t):
    diff = 0
    for j, c in enumerate(T):
        if (c != S[i + j]):
            diff += 1
    result = min(result, diff)
    i += 1

print(result)

Submission status: Accepted

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

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

result = len_t
i = 0

while (i <= len_s - len_t):
    diff = 0
    for j, c in enumerate(T):
        if (c != S[i + j]):
            diff += 1
    # result = min(result, diff)
    if (diff < result):
        result = diff

    i += 1

print(result)

Submission status: Accepted

Solution code:
s = input()
t = input()
s_len = len(s)
t_len = len(t)

ans = 99999

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

print(ans)

Submission status: Accepted

Solution code:
S, T = [input() for i in range(2)]
ans = 0

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

print(len(T)-ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
ans = 0
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 = max(ans,tmp)
print(lt-ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S =input()
T = input()
n = len(S)-len(T)+1
count = []

for i in range(n):
  c =0
  for p in range(len(T)):
    if S[i+p] != T[p]:
      c += 1
  count.append(c)
  
print(min(count))

Submission status: Accepted

Solution code:
s = input()
t = input()
ans = 10**10
l = len(s) - len(t) + 1
for i in range(l):
  tans = 0
  for j in range(len(t)):
    if s[i+j] != t[j]:
      tans += 1
  ans = min(ans, tans)
print(ans)

Submission status: Accepted

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

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

counter = 10**8
for i in range(s-t+1):
    cnt = 0
    for j in range(t):
        if S[i+j] != T[j]:
            cnt += 1
    if counter > cnt:
        counter = cnt

print(counter)

Submission status: Accepted

Solution code:
strS = input()
strT = input()

strS = list(strS)
strT = list(strT)

maxRange = 0
l = 0
while l <= (len(strS)-len(strT)):
    m = 0
    count = 0
    while m < (len(strT)):
        if strS[l+m] == strT[m]:
            count += 1
        m += 1
    if maxRange < count:
        maxRange = count
    l += 1

print(len(strT)-maxRange)

Submission status: Accepted

Solution code:
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 not s[i+j] == t[j]:
			diff=diff+1
	ans = min(ans, diff)
print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()
x,y = len(S),len(T)
A = [0] * (x-y+1)
for i in range(0, x-y+1):
  count = 0
  j = 0
  for k in range(i, i+y):
    if S[k] != T[j]:
      count += 1
    j += 1
  A[i] = count
print(min(A))

Submission status: Accepted

Solution code:
S=input()
LS=len(S)
T=input()
LT=len(T)

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

Submission status: Accepted

Solution code:
s = input()
t = input()
ans = len(t)
#startが開始位置を決める
#jはtの長さ分sを探索するための変数
for start in range(len(s)-len(t)+1):
    l = 0
    for j in range(len(t)):
        if s[j+start] != t[j]:
            l += 1
    ans = min(ans,l)
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    S = list(input())
    T = list(input())

    t = len(T)
    ans = INF
    for i in range(len(S)):
        s = S[i:i+t]
        if len(s) != t: break

        diff = 0
        for j in range(t):
            diff += s[j] != T[j]
        
        ans = min(ans,diff)

    print(ans)



if __name__ == "__main__":
    main()

Submission status: Accepted

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

print(len(T)-ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = str(input())
t = str(input())
sx = len(s)
tx = len(t)
n = sx - tx + 1
amax = 0
for i in range(n):
  x = 0
  for j in range(tx):
    if s[i+j] == t[j]:
      x += 1
    else:
      pass
  if x > amax:
    amax = x
print(tx - amax)

Submission status: Accepted

Solution code:
s = input()
t= input()
c=0
an = 10**8
for i in range(len(s)-len(t)+1):
    for j in range(i,i+len(t)):

        if s[j]!=t[j-i]:
            c+=1

    an = min(c,an)
    c=0
print(an)

Submission status: Accepted

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


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

print(len(t) - max)

Submission status: Accepted

Solution code:
s = input()
t = input()
ans = 10**8
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)

Submission status: Accepted

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

sl = len(s)
tl = len(t)

ans = tl

for i in range(sl):
    if i < sl - tl + 1:
        ss = s[i:i+tl]
        num = 0
        for j in range(tl):
            if ss[j] != t[j]:
                num += 1
        if num < ans:
            ans = num

print(ans)

Submission status: Accepted

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

max_tmp = 0
out = 0


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


for i in range(len(s) - len(t) + 1):
    max_tmp = comp(s[i:i + len(t)], t)
    out = max(out, max_tmp)

print(len(t) - out)

Submission status: Accepted

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

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

ans = len(t) - max_match

print(ans)

Submission status: Accepted

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

import math
res = math.inf

from collections import Counter

mt = list(map(ord, list(T)))
for i in range(len(S) - len(T) + 1):
    # print(S[i: i + len(T)], [a - b for a, b in zip(map(ord, list(S[i: i + len(T)])), mt)])
    res = min(res, len(T) - Counter([a - b for a, b in zip(map(ord, list(S[i: i + len(T)])), mt)])[0])
print(res)

Submission status: Accepted

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

mindiff = len(S)
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
        pass
    if(diff < mindiff):
        mindiff = diff

print(mindiff)

Submission status: Accepted

Solution code:
S=str(input())
T=str(input())


U=[0]*(len(S)-len(T)+1)
c=[0]*(len(S)-len(T)+1)
for j in range(len(S)-len(T)+1):
    U[j]=S[j:j+len(T)]
    for i in range(len(T)):
        if U[j][i]==T[i] :c[j]=c[j]+1

print(len(T)-max(c))