#P6700. [PA 2015 Final] Edycja
[PA 2015 Final] Edycja
Description
Given two lowercase strings A and B of the same length , you may perform the following two operations:
- Change the character at some position in A to another character, which takes 1 second. For example:
ababcbecomesababa. - Change all occurrences of some character in A into another character, which takes seconds. For example:
ababcbecomesacacc.
You can perform only one operation at a time. Find the minimum total time needed to transform A into B.
Input Format
The first line contains two positive integers , representing the string length and the cost of operation 2.
The second line contains a lowercase string A of length .
The third line contains a lowercase string B of length .
Output Format
Output one integer, the minimum total time needed to transform A into B.
5 2
aaabc
bbbaa
4
Hint
Sample Explanation
First, change all a into b, then change the b at position 4 and the c at position 5 into a.
Constraints
For all testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号