#include <bits/stdc++.h>
int main() {
  char s1[6010], s2[2010], s3[2010];
  scanf("%s%s", s1, s2);
  int len1, len2, m = -1, temp, i, j, k, l = 0;
  len1 = (int)strlen(s1);
  len2 = (int)strlen(s2);
  if (len1 < len2) {
    strcpy(s3, s1);
    strcpy(s1, s2);
    strcpy(s2, s3);
    temp = len1;
    len1 = len2;
    len2 = temp;
    l = len1 - len2;
  }
  strcpy(s3, s1);
  for (i = 0; i < len2 - 1; i++) s1[i] = 'A';
  for (j = 0; i < len1 + len2 - 1; i++, j++) s1[i] = s3[j];
  for (i = 0; i < len2 - 1; i++) s1[len1 + len2 - 1 + i] = 'A';
  for (i = 0; i <= len1 + len2 - 2; i++) {
    k = i;
    temp = 0;
    for (j = 0; j < len2; j++, k++) {
      if (s2[j] == s1[k]) temp++;
    }
    if (temp > m) m = temp;
  }
  printf("%d\n", len2 - m + l);
}
