#include <bits/stdc++.h>
using namespace std;
int find(const char* s, const char* t) {
  const int sl = strlen(s);
  const int tl = strlen(t);
  vector<vector<int> > F(sl);
  for (int i = 0; i < sl; ++i) {
    F[i].resize(tl);
  }
  for (int j = 0; j < tl; ++j) {
    F[0][j] = j + (s[0] != t[j]);
  }
  for (int i = 1; i < sl; ++i) {
    for (int j = 0; j < tl; ++j) {
      if (j == 0) {
        F[i][j] = (s[i] != t[0]);
      } else {
        F[i][j] = F[i - 1][j - 1] + (s[i] != t[j]);
      }
    }
  }
  int m = INT_MAX;
  for (int i = 0; i < sl; ++i) {
    for (int j = 0; j < tl; ++j) {
      int tmp = F[i][j] + tl - j - 1;
      if (tmp < m) {
        m = tmp;
      }
    }
  }
  return m;
}
int main(int argc, char** argv) {
  char s[2001];
  char t[2001];
  cin >> s >> t;
  cout << find(s, t) << endl;
}
