#include <bits/stdc++.h>
using namespace std;
char a[10010];
char b[10010];
vector<int> v[10010];
int mp[10010];
void solve() {
  scanf("%s%s", a, b);
  int n = strlen(a);
  int m = strlen(b);
  int minn = 10000000;
  for (int i = 0; i < n; i++) {
    int ans = 0;
    for (int j = i;; j++) {
      if (j - i == m || j == n) {
        minn = min(m - ans, minn);
        break;
      }
      if (b[j - i] == a[j]) {
        ans++;
      }
    }
  }
  for (int i = 0; i < m; i++) {
    int ans = 0;
    for (int j = i;; j++) {
      if (j - i == n || j == m) {
        minn = min(m - ans, minn);
        break;
      }
      if (a[j - i] == b[j]) {
        ans++;
      }
    }
  }
  printf("%d\n", minn);
}
int main() { solve(); }
