#include <bits/stdc++.h>
using namespace std;
struct point {
  double x, y;
};
const int maxn = (int)1e6 + 100;
char a[10000], b[3000], c[10000];
int l1, l2;
void solve() {
  scanf("%s %s", c, b);
  l2 = strlen(b);
  for (int i = 0; i < l2; i++) {
    a[i] = '!';
  }
  l1 = strlen(c);
  for (int i = l2; i < l2 + l1; i++) {
    a[i] = c[i - l2];
  }
  a[l1 + l2] = 0;
  l1 = strlen(a);
  l2 = strlen(b);
  int gans = l1 + l2;
  for (int i = 0; i < l1; i++) {
    int ans = 0;
    for (int j = 0; j + i < l1 && j < l2; j++) {
      if (a[i + j] != b[j]) {
        ans++;
      }
    }
    if (i + l2 > l1) {
      ans += i + l2 - l1;
    }
    gans = min(gans, ans);
  }
  printf("%d\n", gans);
}
void initFiles() {}
int main() {
  initFiles();
  solve();
  return 0;
}
