#include <bits/stdc++.h>
using namespace std;
int main() {
  char s1[2050];
  char s2[2050];
  int delta = 0;
  scanf("%s%s", s1, s2);
  if (strlen(s1) < strlen(s2)) {
    char tmp[2050];
    memcpy(tmp, s1, sizeof(tmp));
    memcpy(s1, s2, sizeof(s1));
    memcpy(s2, tmp, sizeof(s2));
    delta = strlen(s1) - strlen(s2);
  }
  int l1 = strlen(s1);
  int l2 = strlen(s2);
  int mn = 100500;
  for (int i1 = 0; i1 <= l1 - l2; i1++) {
    int cur = 0;
    for (int i2 = 0; i2 < l2; i2++)
      if (s1[i2 + i1] != s2[i2]) cur++;
    if (cur < mn) mn = cur;
  }
  for (int i2 = 0; i2 < l2; i2++) {
    int cur = i2;
    for (int i1 = 0; i1 < l2 - i2; i1++)
      if (s1[i1] != s2[i2 + i1]) cur++;
    if (cur < mn) mn = cur;
    cur = l2 - i2 - 1;
    for (int i1 = l1 - i2 - 1; i1 < l1; i1++)
      if (s1[i1] != s2[i1 - l1 + i2 + 1]) cur++;
    if (cur < mn) mn = cur;
  }
  printf("%d\n", delta + mn);
  return 0;
}
