#include <iostream>
#define forn(i, n) for (int i = 0; i < n; i++)
using namespace std;
const int oo = 2e5 + 7;
int dp[oo][10];
string t, s;
int gdp(int x, int y) {
    if (dp[x][y] != -1) return dp[x][y];
    if (t[x] == s[y] && y == 0) dp[x][y] = 1 + gdp(x-1, y);
    else if (t[x] == s[y]) dp[x][y] = min(gdp(x-1, y-1), 1 + gdp(x-1, y));
    else dp[x][y] = gdp(x-1, y);
    return dp[x][y];
}
int n, m;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> t >> s;
    n = t.size(), m = s.size();
    forn(i, n) forn(j, m) dp[i][j] = -1;
    forn(j, m) dp[0][j] = m == 1 ? t[0] == s[0] : 0;
    cout << gdp(n-1, m-1) << endl;
    system("pause");
}