arr = list(map(str, input().split()))
a = arr[0]
b = arr[1]
# Declaring array 'D' with rows = len(a) + 1 and columns = len(b) + 1:
D = [[0 for i in range(len(b) + 1)] for j in range(len(a) + 1)]
# Initialising first row:
for i in range(len(a) + 1):
D[i][0] = i
# Initialising first column:
for j in range(len(b) + 1):
D[0][j] = j
for i in range(1, len(a) + 1):
for j in range(1, len(b) + 1):
if a[i - 1] == b[j - 1]:
D[i][j] = D[i - 1][j - 1]
else:
# Adding 1 to account for the cost of operation
insertion = 1 + D[i][j - 1]
deletion = 1 + D[i - 1][j]
replacement = 1 + D[i - 1][j - 1]
# Choosing the best option:
D[i][j] = min(insertion, deletion, replacement)
print(D[len(a)][len(b)])
YXJyID0gbGlzdChtYXAoc3RyLCBpbnB1dCgpLnNwbGl0KCkpKQphID0gYXJyWzBdCmIgPSBhcnJbMV0KIyBEZWNsYXJpbmcgYXJyYXkgJ0QnIHdpdGggcm93cyA9IGxlbihhKSArIDEgYW5kIGNvbHVtbnMgPSBsZW4oYikgKyAxOgpEID0gW1swIGZvciBpIGluIHJhbmdlKGxlbihiKSArIDEpXSBmb3IgaiBpbiByYW5nZShsZW4oYSkgKyAxKV0KIAojIEluaXRpYWxpc2luZyBmaXJzdCByb3c6CmZvciBpIGluIHJhbmdlKGxlbihhKSArIDEpOgogICAgRFtpXVswXSA9IGkKIAojIEluaXRpYWxpc2luZyBmaXJzdCBjb2x1bW46CmZvciBqIGluIHJhbmdlKGxlbihiKSArIDEpOgogICAgRFswXVtqXSA9IGoKIApmb3IgaSBpbiByYW5nZSgxLCBsZW4oYSkgKyAxKToKICAgIGZvciBqIGluIHJhbmdlKDEsIGxlbihiKSArIDEpOgogICAgICAgIGlmIGFbaSAtIDFdID09IGJbaiAtIDFdOgogICAgICAgICAgICBEW2ldW2pdID0gRFtpIC0gMV1baiAtIDFdCiAgICAgICAgZWxzZToKICAgICAgICAgICAgIyBBZGRpbmcgMSB0byBhY2NvdW50IGZvciB0aGUgY29zdCBvZiBvcGVyYXRpb24KICAgICAgICAgICAgaW5zZXJ0aW9uID0gMSArIERbaV1baiAtIDFdCiAgICAgICAgICAgIGRlbGV0aW9uID0gMSArIERbaSAtIDFdW2pdCiAgICAgICAgICAgIHJlcGxhY2VtZW50ID0gMSArIERbaSAtIDFdW2ogLSAxXQogCiAgICAgICAgICAgICMgQ2hvb3NpbmcgdGhlIGJlc3Qgb3B0aW9uOgogICAgICAgICAgICBEW2ldW2pdID0gbWluKGluc2VydGlvbiwgZGVsZXRpb24sIHJlcGxhY2VtZW50KQogCnByaW50KERbbGVuKGEpXVtsZW4oYildKQ==