#include <fstream>
#include <cstring>
using namespace std;
const int MAXN(1001);
int n, m, k, f[MAXN][MAXN];
char s[MAXN], t[MAXN];
main()
{
ifstream a("edita.in");
ofstream o("edita.out");
a >> s;
n = strlen(s);
a >> t;
m = strlen(t);
for (int i = 1; i <= n; i++)
f[i][0] = i;
for (int i = 1; i <= m; i++)
f[0][i] = i;
for (int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
f[i][j]=min(min(f[i-1][j],f[i][j-1])+1,f[i-1][j-1]+(int)(s[i-1]!=t[j-1]));
o << f[n][m];
}