#include <bits/stdc++.h>
using namespace std;
int dp[2005][2005], m, ans;
char s[2005], t[2005];
int main() {
  int n = strlen(gets(s + 1));
  ans = m = strlen(gets(t + 1));
  for (int i = n; i >= 1; i--)
    for (int j = m; j >= 1; j--) {
      dp[i][j] = dp[i + 1][j + 1] + (s[i] != t[j]);
      ans = min(ans, dp[i][j] + max(m - j - n + i, 0) + j - 1);
    }
  printf("%d\n", ans);
}
