#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int dp[1005][1005] = { 0 };
int main() {
	string x, y;
	cin >> x >> y;
	for (int i = 0; i < 1005; i++) dp[i][0] = i;
	for (int i = 0; i < 1005; i++) dp[0][i] = i;
	for (int j = 1; j <= x.size(); j++) {
		for (int k = 1; k <= y.size(); k++) {
			if (x[j-1] == y[k-1]) {
				dp[j][k] = min(dp[j - 1][k] + 1, dp[j][k - 1] + 1);
				dp[j][k] = min(dp[j][k], dp[j - 1][k - 1]);
			}
			else {
				dp[j][k] = min(dp[j - 1][k] + 1, dp[j][k - 1] + 1);
				dp[j][k] = min(dp[j][k], dp[j - 1][k - 1] + 1);
			}
		}
	}
	cout << dp[x.size()][y.size()] << endl;
	return 0;
}
