#include <bits/stdc++.h>
using namespace std;
const int oo = (int)1e9;
const double PI = 2 * acos(0.0);
const double eps = 1e-7;
int dx[] = {1, 0, 0, -1, -1, -1, 1, 1};
int dy[] = {0, 1, -1, 1, 1, -1, 1, -1};
int dp[2002][2002];
string a, b;
int fun(int idxa, int idxb) {
  if (idxa == ((int)((a).size()))) return ((int)((b).size())) - idxb;
  if (idxb == ((int)((b).size()))) return 0;
  int &ret = dp[idxa][idxb];
  if (ret != -1) return ret;
  if (a[idxa] == b[idxb]) return fun(idxa + 1, idxb + 1);
  int ch = 1 + fun(idxa + 1, idxb);
  ch = min(ch, 1 + fun(idxa, idxb + 1));
  return ret = ch;
}
int main() {
  cin >> a >> b;
  memset(dp, -1, sizeof(dp));
  int mn = 1e7;
  for (int i = 0; i < ((int)((a).size())); i++) mn = min(mn, fun(i, 0));
  cout << mn << endl;
}
