Edit Distance

No attempts yetTime limit8sMemory limit128 MB

Problem

Consider an edit script that turns string AA into string BB. An edit script is made of the four commands below, and each command consumes AA from the front while building the result string.

  • Add (a): output one character to the result. AA is left untouched.
  • Delete (d): remove the first character of AA and output nothing.
  • Modify (m): remove the first character of AA and output a different character instead.
  • Copy (c): remove the first character of AA and output that same character.

Copy is free. The length of an edit script is the number of add, delete, and modify commands it uses, and the shortest edit script is the one that minimizes the count of these three commands.

Given two strings AA and BB, find the minimum number of add, delete, and modify commands (the edit distance) used by a shortest edit script that turns AA into BB.

Input

The first line contains string AA and the second line contains string BB. Both strings consist only of English letters (uppercase and lowercase) and digits, and each has length between 11 and 1700017000, inclusive.

Output

Print a single integer: the minimum number of add, delete, and modify commands needed to turn AA into BB.