#include <bits/stdc++.h>
using namespace std;
char s[4005], t[4005], ax[4005];
int main() {
  scanf("%s%s", s, t);
  int n = strlen(s), m = strlen(t), ret = m;
  for (int i = n - 1; i >= 0; i--) s[i + m] = s[i], s[i] = 0;
  n += m;
  for (int i = 0; i < n; i++) {
    int ct = 0;
    for (int j = 0; j < m; j++) {
      if (i + j >= n || s[i + j] != t[j]) ct++;
    }
    ret = min(ret, ct);
    ct = 0;
    for (int j = 0; j < m; j++) {
      if (i - j < 0 || s[i - j] != t[m - 1 - j]) ct++;
    }
    ret = min(ret, ct);
  }
  printf("%d\n", ret);
  return 0;
}
