#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int const N=1e3+7;
int const INF=0x3f3f3f3f;
string s,t;
int f[N][N];  //f[i][j]表示s的前i个字符包含前j个字符需要修改的字符 
int main(){
    cin >> s >> t;
    int sl=s.size(),tl=t.size();
    f[0][1]=INF;
    for(int i=1;i<=sl;++i){
        for(int j=1;j<=tl;++j){
            if(j>i){
                f[i][j]=INF;break;
            }
            if(s[i-1]==t[j-1]){
                f[i][j]=f[i-1][j-1];
            }
            else f[i][j]=min(f[i-1][j],f[i-1][j-1]+1);
        }
    }
    cout << f[sl][tl];
    return 0;
}