#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1E-9;
const int INF = (int)1E9;
const long long INF64 = (long long)1E18;
string a, b;
int M[2001][2001][2];
int f(int in1, int in2, int fl) {
  if (M[in1][in2][fl] != -1) return M[in1][in2][fl];
  if (in2 >= b.size()) return M[in1][in2][fl] = 0;
  if (in1 >= a.size()) return M[in1][in2][fl] = b.size() - in2;
  int ans = INF;
  if (fl == 0) ans = min(ans, f(in1, in2 + 1, 0) + 1);
  if (a[in1] == b[in2]) {
    ans = min(ans, f(in1 + 1, in2 + 1, 1));
  }
  ans = min(ans, f(in1 + 1, in2 + 1, 1) + 1);
  if (fl == 0) ans = min(ans, f(in1 + 1, in2, 0) + 1);
  return M[in1][in2][fl] = ans;
}
int main() {
  cin >> a >> b;
  memset(M, (-1), sizeof(M));
  int ans = INF;
  for (int i = 0; i < (int)(a.size()); i++) {
    ans = min(f(i, 0, 0), ans);
  }
  cout << ans;
}
