word1 = input()
word2 = input()
m = len(word1)
n = len(word2)
table = [[0] * (n + 1) for _ in range(m + 1)]
for i in range(m + 1):
table[i][0] = i
for j in range(n + 1):
table[0][j] = j
for i in range(1, m + 1):
for j in range(1, n + 1):
if word1[i - 1] == word2[j - 1]:
table[i][j] = table[i - 1][j - 1]
# if same move on
else:
table[i][j] = 1 + min(table[i - 1][j], table[i]
[j - 1], table[i - 1][j - 1])
# else check min of removing one from word1, one from word2, or both
print(table[-1][-1])
d29yZDEgPSBpbnB1dCgpCndvcmQyID0gaW5wdXQoKQogCm0gPSBsZW4od29yZDEpCm4gPSBsZW4od29yZDIpCnRhYmxlID0gW1swXSAqIChuICsgMSkgZm9yIF8gaW4gcmFuZ2UobSArIDEpXQogCmZvciBpIGluIHJhbmdlKG0gKyAxKToKICAgIHRhYmxlW2ldWzBdID0gaQogICAgCmZvciBqIGluIHJhbmdlKG4gKyAxKToKICAgIHRhYmxlWzBdW2pdID0gagogCmZvciBpIGluIHJhbmdlKDEsIG0gKyAxKToKICAgIGZvciBqIGluIHJhbmdlKDEsIG4gKyAxKToKICAgICAgICBpZiB3b3JkMVtpIC0gMV0gPT0gd29yZDJbaiAtIDFdOgogICAgICAgICAgICB0YWJsZVtpXVtqXSA9IHRhYmxlW2kgLSAxXVtqIC0gMV0KIyAgICAgICAgICAgICAgICAgICAgIGlmIHNhbWUgbW92ZSBvbgogICAgICAgIGVsc2U6CiAgICAgICAgICAgIHRhYmxlW2ldW2pdID0gMSArIG1pbih0YWJsZVtpIC0gMV1bal0sIHRhYmxlW2ldCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBbaiAtIDFdLCB0YWJsZVtpIC0gMV1baiAtIDFdKQojICAgICAgICAgICAgIGVsc2UgY2hlY2sgbWluIG9mIHJlbW92aW5nIG9uZSBmcm9tIHdvcmQxLCBvbmUgZnJvbSB3b3JkMiwgb3IgYm90aApwcmludCh0YWJsZVstMV1bLTFdKQ==