cswork / OAOpen practice workspace

IBMOA #59

Minimum Moves to Match Arrays

Estimated EasyJudge-ready

Topics (AI-labelled)Bits & MathSimulation

Corresponding integers in the two arrays have the same number of digits. Each operation increases or decreases one decimal digit of some integer in arr1 by 1, without going outside 0..9, without carrying, and without moving digits. Find the minimum number of operations to make it identical to arr2. This is the operation explained digit by digit in the source's first example.

Input

The first line contains n, the second line contains arr1, and the third line contains arr2. 1≤n≤100000, 1≤element≤10^9, the two arrays have the same length, and each pair of corresponding integers has the same number of decimal digits.

Output

Output one integer, the answer.

Example 1

Input:

2
1234 4321
2345 3214

Output:

10

Example 2

Input:

1
1248
8642

Output:

17

Example 3

Input:

1
9
1

Output:

8

Example notes

The examples give 10, 17 and 8 respectively. In the second example, the original output 16 and the explanation's 15 are both incorrect: 7+4+0+6=17.

Editorial

Loading solution…