4.4 Wordonia's Wizad
(RankList for this Question)
Score: 25pts
Time Limit: 1.00 sec
In a whimsical realm known as "Wordonia," there lived a cunning linguistic wizard named Lexo. Lexo was renowned far and wide for his extraordinary ability to perform mystical transformations on words using a trio of enchanted spells.

The spells were:

1. "Addition Potion": A sparkling elixir that allowed Lexo to add a letter to a word, as if weaving it into the very fabric of language.

2. "Removal Elixir": A shimmering brew that enabled him to remove a letter from a word, making it vanish into thin air.

3. "Substitution Charm": A mystical incantation that let Lexo replace one letter with another, altering the essence of the word.

One fateful day, Lexo received a mysterious letter from the Wordonian Council. They had a grand challenge for him: to embark on an epic quest through the linguistic wilderness of Wordonia and calculate the minimum number of enchanted spells required to transform any word into another.

Lexo, always up for a linguistic adventure, accepted the quest with gusto. He donned his spellcasting robes, grabbed his trusty dictionary staff, and set out on an adventure filled with twists and turns. Along the way, he encountered curious creatures made of letters and punctuation marks, and he unraveled riddles hidden within ancient scrolls.

As Lexo ventured deeper into Wordonia, he discovered that every word held a unique enchanting path to another. Whether it was changing "LOVE" into "MOVIE" or "CASTLE" into "DRAGON," he relied on his magical trio of spells to forge the most efficient linguistic bridges.

Your task is to join Lexo on this enchanting journey and help him calculate the minimum number of spells needed to navigate the captivating world of word transformations in Wordonia. So, dust off your spellbook and embark on an adventure where language and magic intertwine!

Constraints
1≤n,m≤5000

Input Format
The first input line has a string that contains n characters between A–Z.

The second input line has a string that contains m characters between A–Z.

Output Format
Print one integer: the edit distance between the strings.

Example 1
Input:
LOVE
MOVIE

Output:
2

Explanation:
Step 1: You will use the 3rd spell to substitute L with M
Step 2: To add add I Addition portion will be used

Log In to solve the Question