#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<cstdio>

using namespace std;

int dp[1001][1001];

int main() {
	string m1, m2;

	cin >> m1 >> m2;

	memset(dp, 0x7f, sizeof(dp));
	int m = m1.size();
	int mm = m2.size();

	for (int i = 0; i <= mm; i++) dp[0][i] = i;
	for (int i = 0; i <= m; i++) dp[i][0] = i;

	for (int i = 0; i < m; i++) {
		for (int j = 0; j < mm; j++) {
			dp[i + 1][j + 1] = min(dp[i][j], min(dp[i + 1][j], dp[i][j + 1]))+1;
			if (m1[i] == m2[j]) dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j]);
		}
	}
	
	printf("%d\n", dp[m][mm]);
}
