#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int dp[2005][2005];
string s1;
string s2;
int main() {
  cin >> s1;
  cin >> s2;
  int ans = 0;
  int l1 = s1.length();
  int l2 = s2.length();
  for (int i = l1 - 1; i >= 0; i--) {
    for (int j = l2 - 1; j >= 0; j--) {
      dp[i][j] = (s1[i] == s2[j]) + dp[i + 1][j + 1];
      ans = max(ans, dp[i][j]);
    }
  }
  cout << l2 - ans << endl;
  return 0;
}
