Mystic Move

View as PDF

Submit solution


Points: 1
Time limit: 1.0s
Memory limit: 256M

Problem types

In the mystical town of cclub, there lived two curious friends named İlke and Burak. İlke, an imaginative thinker, and Burak, a master of patterns, loved unraveling mysteries.

İlke and Burak come across an ancient wall decorated with magic stones. According to legend, the stones held the key to unlock a mysterious door protected by a powerful protection spell. As they observed, there was a magical entity that could generate stones with specific letters.

İlke and Burak realized that removing and replacing these lettered stones on the wall or inserting new lettered stones to the wall from the magical entity could unveil the hidden words that would dispel the protection on the magical door.

However, there was a tricky part to the challenge – every time İlke and Burak made a move to manipulate the stones, the magical door would shrink. To fit through the door once the protection was removed, İlke and Burak needed to minimize the number of operations.

They need your help to find this minimal number. Can you help them?

Input

  • In the first line, space separated two numbers, \(a\) and \(b\), which represent the length of the words will be given respectively.

  • In the second line, the initial word will be given. In the third line, the desired word will be given.

  • \(0 \leq a, b \leq 2^{12}\)

The words will contain only lowercase english characters.

Output

Print the minimum number of operations to acquire the second word from the first word.

Examples

Input 1:

3 4
can
chan

Output 1:

1

Input 2:

8 8
kutukola
sisekola

Output 2:

4

Explanation

Input 1:

By inserting stone with letter h, we can acquire the second word. So, the answer is 1.

Input 2:

The second word can be acquired by replacing the first 4 letters of the first word.