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()
ans = 10**10
for i in range(len(s)-len(t)+1):
    b = 0
    for j in range(len(t)):
        if s[i+j]!=t[j]:
            b += 1
    ans = min(ans,b)
print(ans)

Submission status: Accepted

Solution code:
# ===============================================================================================
# importing some useful libraries.
from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter  # Counter(list)  return a dict with {key: count}
from itertools import combinations as comb  # if a = [1,2,3] then print(list(comb(a,2))) -----> [(1, 2), (1, 3), (2, 3)]
from itertools import permutations as permutate
from bisect import bisect_left as bl
# If the element is already present in the list,

# the left most position where element has to be inserted is returned.
from bisect import bisect_right as br
from bisect import bisect

# If the element is already present in the list,
# the right most position where element has to be inserted is returned

# ==============================================================================================
# fast I/O region

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None


    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

# inp = lambda: sys.stdin.readline().rstrip("\r\n")

# ===============================================================================================
### START ITERATE RECURSION ###
from types import GeneratorType


def iterative(f, stack=[]):
    def wrapped_func(*args, **kwargs):
        if stack: return f(*args, **kwargs)
        to = f(*args, **kwargs)
        while True:
            if type(to) is GeneratorType:
                stack.append(to)
                to = next(to)
                continue
            stack.pop()
            if not stack: break
            to = stack[-1].send(to)
        return to

    return wrapped_func


#### END ITERATE RECURSION ####

# ===============================================================================================
# some shortcuts

mod = 1000000007


def inp(): return sys.stdin.readline().rstrip("\r\n")  # for fast input

def out(var): sys.stdout.write(str(var))  # for fast output, always take string

def lis(): return list(map(int, inp().split()))

def stringlis(): return list(map(str, inp().split()))

def sep(): return map(int, inp().split())

def strsep(): return map(str, inp().split())


def zerolist(n): return [0] * n

def nextline(): out("\n")  # as stdout.write always print sring.

def testcase(t):
    for p in range(t):
        solve()

def printlist(a):
    for p in range(0, len(a)):
        out(str(a[p]) + ' ')

def lcm(a, b): return (a * b) // gcd(a, b)

def power(x, y, p):
    res = 1  # Initialize result
    x = x % p  # Update x if it is more , than or equal to p
    if (x == 0):
        return 0
    while (y > 0):
        if ((y & 1) == 1):  # If y is odd, multiply, x with result
            res = (res * x) % p

        y = y >> 1  # y = y/2
        x = (x * x) % p
    return res

def ncr(n, r): return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
    if (n <= 1): return False
    if (n <= 3): return True
    if (n % 2 == 0 or n % 3 == 0): return False
    i = 5
    while (i * i <= n):
        if (n % i == 0 or n % (i + 2) == 0):
            return False
        i = i + 6
    return True


s=inp()
t=inp()
mi=9999999990999999999
for i in range(len(s)-len(t)+1):
    d=0
    for j in range(i,i+len(t)):
        if s[j]!=t[j-i]:
            d+=1
    mi=min(d,mi)
print(mi)

Submission status: Accepted

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

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

ans = 10000
for i in range(num):
    S_tmp = S[i:i+t]
    tmp_ans = 0
    for j, k in zip(S_tmp, T):
        if j!=k:
            tmp_ans += 1
    
    ans = min(ans, tmp_ans)

print(ans)

Submission status: Accepted

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


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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
T = list(input())
NS = len(S)
NT = len(T)
cnt = NS
for i in range(0,NS-NT+1):
    tmp = 0
    for j in range(NT):
        if S[i+j]!=T[j]:
            tmp+=1
    cnt = min(tmp,cnt)
print(cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
s = input()
t = input()
a ,b = len(s), len(t)
c = INF = float("inf")
for i in range(a - b + 1):
    c = min(c, sum(d != e for d, e in zip(s[i:i+b], t)))
print(c)

Submission status: Accepted

Solution code:
s = input()
t = input()
ans = len(t)
for i in range(1+len(s)-len(t)):
    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 = list(input())
t = list(input())

l = []
for start in range(len(s)-len(t)+1):
    cnt = 0
    for i in range(len(t)):
        if t[i] != s[start+i]:
            cnt += 1
    l.append(cnt)
print(min(l))

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:
s = input()
t = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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
    ans = min(count,ans)

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

s = input()
t = input()

ans = float('inf')

for i in range(len(s)):
    temp = s[i:]
    if len(temp) < len(t):
        break
    cnt = 0
    for j in range(len(t)):
        if temp[j] != t[j]:
            cnt += 1
    ans = min(cnt, ans)
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 + j]:
            cnt += 1
    ans = min(ans, cnt)

print(ans)

Submission status: Accepted

Solution code:
s=input()
t=input()
q=len(s)
w=len(t)
def qwe(s,t):
    ans=0
    for i,j in zip(s,t):
        if i!=j:
            ans+=1
    return ans

ans=10**10
for i in range(q-w+1):
    ans=min(ans, qwe(s[i:i+w], t))
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
T = input()
minA = float("inf")
for i in range(len(S) - len(T) + 1):
    sumA = 0
    for j in range(len(T)):
        if S[i + j] != T[j]:
            sumA += 1
    minA = min(minA, sumA)
print(minA)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

ans = 10**5
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
    ans = min(ans, c)
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit
#input = stdin.buffer.readline
setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18

#N = int(input())
#N, M = map(int, input().split())
#A = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]
#ABC = [list(map(int, input().split())) for _ in range(N)]
S = input()
T = input()
#S = [input() for _ in range(N)]

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# import sys
# import math #sqrt,gcd,pi
# import decimal
import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
    # combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    s = input()
    t = input()
    ans = INF
    for i in range(len(s)-len(t)+1):
        res = 0
        for j in range(len(t)):
            if s[i+j]!=t[j]:
                res += 1
        ans = min(ans,res)
    print(ans)
    return

if __name__=='__main__':
    main()

Submission status: Accepted

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

res = 10 ** 5
for i in range(len(S) - len(T) + 1):
    tmp = 0
    for j in range(len(T)):
        if T[j] != S[i + j]:
            tmp += 1
    res = min(res, tmp)

print(res)

Submission status: Accepted

Solution code:
s=input()
t=input()
mn=len(s)
for i in range(len(s)-len(t)+1):
  cnt=0
  for (x,y) in zip(t,s[i:i+len(t)]):
    if x!=y:
      cnt+=1
  mn=min(cnt,mn)
print(mn)

Submission status: Accepted

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

s = len(S)
t = len(T)
ans = t
for i in range(s - t+1):
    count = 0
    for a, b in zip(S[i:], T):
        if a != b:
            count += 1
    if ans > count:
        ans = count

print(ans)

Submission status: Accepted

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

def count(x,y):
    return sum(xi!=yi for xi,yi in zip(x,y))
    
ans = min(count(s[i:i+len(t)],t) for i in range(len(s)-len(t)+1))
print(ans)

Submission status: Accepted

Solution code:
def resolve():
    s = input()
    t = input()
    ans = 10000
    lens = len(s)
    lent = len(t)
    for i in range(lens - lent + 1):
        x = 0
        for j in range(lent):
            if s[i + j] != t[j]:
                x += 1
        ans = min(ans, x)
    print(ans)


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
s = input() #sys.stdin.readlineは最後が改行
t = input() #sys.stdin.readlineは最後が改行

ans= 1000

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

    ans = min(ans,tmp)

print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

s=SI()
t=SI()
sn=len(s)
tn=len(t)
ans=100000
for i in range(sn-tn+1):
    cur=0
    for j in range(tn):
        cur+=s[i+j]!=t[j]
    ans=min(ans,cur)
print(ans)

Submission status: Accepted

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

ls = len(S)
lt = len(T)
ans = 1<<60
for i in range(ls-lt+1):
    cnt = 0
    X = S[i:i+lt]
    for x, t in zip(X, T):
        if x != t:
            cnt += 1
    ans = min(ans, cnt)
print(ans)

Submission status: Accepted

Solution code:
s=input()
t=input()
ans=1000000
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:
#ここまでテンプレ
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

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

ma = 10**10

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

print(ma)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import *

def calc(i):
    d = 0
    
    for j in range(len(T)):
        if S[i+j]!=T[j]:
            d += 1
    
    return d
    
S = input()[:-1]
T = input()[:-1]
ans = 10**18

for i in range(len(S)-len(T)+1):
    ans = min(ans, calc(i))

print(ans)

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
t=input()
len_s=len(s)
len_t=len(t)
cnt=0
ans=len_s
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
  ans=min(ans,cnt)
print(ans)

Submission status: Accepted

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


def d(s, t):
    cnt = 0
    for i in range(len(s)):
        if s[i] != t[i]:
            cnt += 1
    return cnt


n = len(s)
m = len(t)
ans = 1000000
for i in range(n - m + 1):
    ans = min(ans, d(s[i:i + m], t))
print(ans)

Submission status: Accepted

Solution code:
def main():
    import sys
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline
    S = input().strip()
    T = input().strip()
    ans = float('inf')
    for i in range(len(S)-len(T)+1):
        ans_ = 0
        for j in range(len(T)):
            if S[i+j] != T[j]:
                ans_ += 1
        ans = min(ans, ans_)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    S = input()
    T = input()
    ls = len(S)
    lt = len(T)

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache

#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')
AZ = "abcdefghijklmnopqrstuvwxyz"

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


#####Shorten#####
def DD(arg): return defaultdict(arg)

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n): return kaijo_memo[n]
  if(len(kaijo_memo) == 0): kaijo_memo.append(1)
  while(len(kaijo_memo) <= n): kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n): return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0): gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n): gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if n == r: return 1
  if n < r or r < 0: return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1: arr.append([temp, 1])
  if arr==[]: arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b: a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n-1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n: return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

def base_10_to_n_without_0(X, n):
  X -= 1
  if X//n: return base_10_to_n_without_0(X//n, n)+[X%n]
  return [X%n]

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

A = S()
B = S()

NA = len(A)
NB = len(B)

ans = INF
for i in range(NA-NB+1):
  c = 0
  for j in range(NB):
    if A[i+j] != B[j]:
      c += 1
  ans = min(ans,c)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

s=input()
t=input()
ls=len(s)
lt=len(t)
ans=100000
for i in range(ls-lt+1):
    c=0
    for k in range(lt):
        if s[i+k]!=t[k]:
            c+=1
    ans=min(ans,c)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
T=input()
a=len(S)
b=len(T)
maxa=1000000
for i in range(a-b+1):
  A=S[i:i+b]
  ans=0
  for j in range(b):
    if A[j]!=T[j]:
      ans+=1
  maxa=min(maxa,ans)
print(maxa)

Submission status: Accepted

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

ans = len(T)

def dist(s, t):
    d = 0
    for i in range(len(s)):
        if s[i] != t[i]:
            d += 1
    return d

for offset in range(len(S)-len(T)+1):
    ans = min(ans, dist(S[offset:(offset+len(T))], T))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
t = input()
ans = float("inf")
for i in range(len(s) - len(t) + 1):
    temp = 0
    for j in range(len(t)):
        if t[j] != s[i + j]:
            temp += 1
    ans = min(ans, temp)
print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()
ls, lt = len(s), len(t)
ans = float("inf")
for i in range(ls - lt + 1):
    cnt = 0
    s2 = s[i:i + lt]
    for j in range(lt):
        if s2[j] != t[j]:
            cnt += 1
    ans = min(ans, cnt)
print(ans)

Submission status: Accepted

Solution code:

S = input()
T = input()

n = len(S)
m = len(T)
res = n + 1
for i in range(n - m + 1):
    cnt = 0
    for j in range(m):
        cnt += int(S[i + j] != T[j])
    res = min(res, cnt)

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = str(input())
t = str(input())
n = len(s)
m = len(t)
ans = float("inf")
for i in range(n-m+1):
  si = s[i:i+m]
  c = 0
  for j in range(m):
    if si[j] != t[j]:
      c += 1
  if c < ans:
    ans = c
print(ans)

Submission status: Accepted

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

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

min_val = 10000

for i in range(sl-tl+1):
    tmp = 0
    for j in range(tl):
        if t[j] != s[j+i]:
            tmp += 1
    min_val = min(min_val, tmp)

print(min_val)

Submission status: Accepted

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

s = input()[:-1]

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
from decimal import *
import heapq
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

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

Submission status: Accepted

Solution code:
def diff(a, b):
    ret = 0
    for c1, c2 in zip(a, b):
        if c1 != c2:
            ret += 1

    return ret

S = input()
T = input()

l = len(T)
ans = 10 ** 9
for i in range(len(S) - l + 1):
    # print(S[i:i+l])
    ans = min(ans, diff(S[i:i+l], T))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:


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

a=input()
b=input()
tot=len(a)

i=0
j=len(b)-1

while j<len(a):
	tot=min(tot,cc(b,a[i:j+1]))
	i+=1
	j+=1

print(tot)

Submission status: Accepted

Solution code:
s = input()
t = input()
ans = len(t)
for i in range(len(s) - len(t) + 1):
    ans = min(ans, sum(si != ti for si, ti in zip(s[i:], t)))
print(ans)

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
ans=len(t)+1
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()
ans = len(T)
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 c < ans:
        ans = c
print(ans)

Submission status: Accepted

Solution code:
S=input()
T=input()
ret = float("inf")
for i in range(len(S)-len(T)+1):
    
    sub = S[i:i+len(T)]
    ans = 0
    for k in range(len(sub)):
        if sub[k] != T[k]:
            ans += 1
    ret = min(ans, ret)
print(ret)

Submission status: Accepted

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

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

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

print(answer)

Submission status: Accepted

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


n = len(S) - len(T) + 1
ans = len(S)

for i in range(n): # スタート位置を全探索
    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:
s=input()
t=input()
ans=10**8
n=len(s);m=len(t)
for i in range(n-m+1):
	cnt=0
	for j in range(m):
		if s[i+j]!=t[j]:
			cnt+=1
	ans=min(ans,cnt)
print(ans)