#include <bits/stdc++.h>
using namespace std;
int pt[2005][2005];
char s[2005], t[2005];
int main() {
  int n = strlen(gets(s + 1));
  int m = strlen(gets(t + 1));
  int ans = m;
  for (int i = n; i >= 1; i--)
    for (int j = m; j >= 1; j--) {
      pt[i][j] = pt[i + 1][j + 1] + (s[i] != t[j]);
      int use = max((m - j) - (n - i), 0);
      ans = min(ans, pt[i][j] + j - 1 + use);
    }
  printf("%d\n", ans);
}
