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 in C++ (GCC 9.2.1) (judge verdict: Wrong Answer)

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define getcx getchar_unlocked
#define MSV(A,a) memset(A, a, sizeof(A))
#define MP make_pair
#define PB push_back
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12
#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define MOD 1000000007
#define MAX 100005
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

int main() {

	string s, t;
	int i, j, k, ls, lt, cnt = 0, ans = INT_MAX, hashs[26] ={0}, hasht[26] ={0};
	vector<int> vec[26];

	cin>>s>>t;
	ls = s.length();
	lt = t.length();

	for(i = 0; i < ls; i++) {
		hashs[s[i] - 'a']++;
		vec[s[i]-'a'].PB(i);
	}


	for(i = 1; i < lt; i++) {
		hasht[t[i] - 'a']++;
	}

	ans = t.length();

	if(s.find(t) != string::npos) {
		ans = 0;
	}


	for(i = 0 ;i < lt; i++) {

		if(vec[t[i]-'a'].size() > 0) {

			for(j = 0; j < vec[t[i]-'a'].size(); j++) {
				cnt = 0;
				k = i-1;
				int z = vec[t[i]-'a'][j]-1;

				///if(t[i] == 'e') {
				//}
				
				if(i > z+1 || (lt - i - 1) > (ls - (z+1))) continue;

				//cout<< "i "<<i << " z " << z << " lt " << lt << " lj "<< ls <<endl;

				while(k >=0 && z >= 0) {

					if(t[k--] != s[z--]) cnt++;
				}

	//if(t[i] == 'e') {
	//				cout<< "i "<<i << " j " << z << " lt " << lt << " lj "<< ls << " cnt " << cnt<<endl;
	//			}
				//cout<< " T I " <<i << " CNT " <<cnt<<endl;

				k = i+1;
				z = vec[t[i] - 'a'][j] + 1;

			//	cout<< " Z " <<z<<endl;

				while(k < lt && z < ls) {
					if(t[k++] != s[z++]) cnt++;
				}

				//cout<< " cNT " <<cnt<<endl;


				if(cnt == 0) continue;

				ans = min(ans, cnt);
			}

		}
	}

	cout<<ans<<en;
	return 0;
}