#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
char s[2005], t[2005];
int main() {
  scanf("%s %s", s, t);
  int ls = strlen(s), lt = strlen(t);
  int ans = 1e9;
  for (int i = 0, ii, j; i < ls; i++) {
    int res = 0;
    for (ii = i, j = 0; ii < ls && j < lt; ii++, j++) {
      if (s[ii] != t[j]) res++;
    }
    if (j < lt) res += lt - j;
    ans = min(ans, res);
  }
  for (int j = 0, i, jj; j < lt; j++) {
    int res = 0;
    for (i = 0, jj = j; i < ls && jj < lt; i++, jj++) {
      if (s[i] != t[jj]) res++;
    }
    if (jj < lt) res += lt - jj;
    res += j;
    ans = min(ans, res);
  }
  cout << ans << endl;
  return 0;
}
