cho.sh
Notes
Loading...

Minimum Edit Distance 2

Time limit

2s

Memory limit

128 MB

Problem

Given two strings X and Y, transform X into Y using the following edit operations. Each operation counts as one edit.

  1. Insert: insert one lowercase English letter at any position in X.
  2. Delete: delete one character from X.
  3. Replace: replace one character of X with another lowercase English letter.
  4. Swap: swap the positions of two adjacent characters in X.

Find the minimum number of edit operations needed to make X equal to Y.

Input

The first line contains string X, and the second line contains string Y. Each string has length between 1 and 1,000, inclusive, and consists only of lowercase English letters.

Output

Print the minimum number of edit operations needed to transform X into Y.