#include <bits/stdc++.h>
using namespace std;
long long ans, len;
long long dp[2005][2005];
int main() {
  std::ios::sync_with_stdio(false);
  string s, u;
  cin >> s >> u;
  len = u.length();
  for (int i = s.length() - 1; i >= 0; i--) {
    for (int j = u.length() - 1; j >= 0; j--) {
      dp[i][j] = dp[i + 1][j + 1];
      if (s[i] == u[j]) {
        dp[i][j]++;
      }
      ans = max(ans, dp[i][j]);
    }
  }
  cout << len - ans;
}
