#include <bits/stdc++.h>
using namespace std;
int n, m, k, sol = 1000000000;
char A[10010], B[10010], V[10010];
int main() {
  scanf("%s", A + 1);
  A[0] = ' ';
  scanf("%s", B + 1);
  B[0] = ' ';
  n = strlen(A) - 1;
  m = strlen(B) - 1;
  V[0] = ' ';
  for (int i = 1; i <= m; i++) V[i] = '?';
  for (int i = m + 1; i <= m + n; i++) V[i] = A[i - m];
  for (int i = m + n + 1; i <= 2 * m + n; i++) V[i] = '?';
  k = 2 * m + n;
  for (int i = 1; i + m - 1 <= k; i++) {
    int cost = 0;
    for (int j = i; j <= i + m - 1; j++)
      if (V[j] != B[j - i + 1]) cost++;
    sol = min(sol, cost);
  }
  printf("%d\n", sol);
  return 0;
}
