#include <bits/stdc++.h>
const int INF = 0x7fffffff;
const double inf = 1e8;
const double eps = 1e-10;
const double PI = acos(-1.0);
const int Max = 3001;
using namespace std;
char a[Max];
char b[Max];
int main() {
  scanf("%s", a);
  scanf("%s", b);
  int n = strlen(a);
  int m = strlen(b);
  int ans = n + m;
  for (int i = 0; i <= m; i++) {
    int tmp = i;
    int k;
    for (k = 0; k < n && i + k < m; k++) {
      if (a[k] == b[i + k])
        continue;
      else
        tmp++;
    }
    if (k + i < m) {
      tmp += (m - k - i);
    }
    if (tmp < ans) ans = tmp;
  }
  for (int i = 0; i <= n; i++) {
    int tmp = 0;
    int k;
    for (k = 0; k < m && k + i < n; k++) {
      if (b[k] == a[i + k])
        continue;
      else
        tmp++;
    }
    if (k < m) {
      tmp += (m - k);
    }
    if (tmp < ans) ans = tmp;
  }
  printf("%d\n", ans);
  return 0;
}
