#include <bits/stdc++.h>
using namespace std;
const int MAX = 2005;
char s[MAX], t[MAX];
int ret, l1, l2, dp[MAX][MAX];
int main() {
  scanf("%s%s", s + 1, t + 1);
  l1 = strlen(s + 1), l2 = strlen(t + 1);
  for (int i = 1; i <= (l1); i++)
    for (int j = 1; j <= (l2); j++)
      dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + (s[i] == t[j])),
      ret = max(ret, dp[i][j]);
  printf("%d\n", l2 - ret);
  return 0;
}
