( Problem A ) Pikachu and the Game of Strings

3.9

60 votes
Algorithms, Easy, Greedy Algorithms
Problem

Pikachu has recently learnt a new move . He knows he can work hard and convert it into a stronger move . Both the moves  and  contain the same number of letters.

In a single day, Pikachu can increase any letter of move  by one, that is, in a single day, he can convert letter to , to , to and so on. He can also convert letter to letter

Pikachu just realized he also has a hidden ability. It can help him increase any letter of move  by ,  that is, in a single day, he can convert letter to letter , into , into , into and so on.  

Now Pikachu wants to know the minimum number of days in which he can convert the move into move   ?
 

Constraints:

  • s and consists of uppercase English letters only

Input format:

  • First line contains an integer , the length of strings and
  • Second line contains string of length
  • Third line contains string of length  

Output format:

  • Output single line containing the minimum number of days required
Sample Input
4
ABCT
PBDI
Sample Output
7
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Pikachu can convert move s into t in 7 days as follows:

  1. (1st letter)
  2.   (1st letter)
  3.   (1st letter)
  4. (3rd letter)
  5. (4th letter)
  6. (4th letter)
  7. (4th letter)
Contributers:
Editor Image

?