#include <bits/stdc++.h>
using namespace std;
int memo[2003][2003];
int main() {
  int n;
  string s, t;
  while (cin >> s >> t) {
    int n1 = s.size();
    int n2 = t.size();
    s = "*" + s;
    t = "*" + t;
    for (int i = 1; i <= n1; i++) memo[0][i] = i;
    for (int i = 1; i <= n2; i++)
      for (int j = 1; j <= n1; j++)
        memo[i][j] = (t[i] != s[j]) + memo[i - 1][j - 1];
    int ans = (1 << 30);
    for (int i = 1; i <= n2; i++) {
      for (int j = 1; j <= n1; j++) {
        if (i >= j)
          ans = min(ans, n2 - i + abs(i - j) + memo[i][j]);
        else
          ans = min(ans, n2 - i - abs(i - j) + memo[i][j]);
      }
    }
    cout << ans << endl;
  }
}
