Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock.

The combination lock is represented by *n* rotating disks with digits from 0 to 9 written on them. Scrooge McDuck has to turn some disks so that the combination of digits on the disks forms a secret combination. In one move, he can rotate one disk one digit forwards or backwards. In particular, in one move he can go from digit 0 to digit 9 and vice versa. What minimum number of actions does he need for that?
The first line contains a single integer *n* (1 ≤ *n* ≤ 1000) — the number of disks on the combination lock.

The second line contains a string of *n* digits — the original state of the disks.

The third line contains a string of *n* digits — Scrooge McDuck's combination that opens the lock.
"""
-- Algorithm --
1) take n of disks
2) take the first row and second row and store each in a list
3) zip both into new list compresed of pairs
4) iterate over each pair and compare increasing steps and decreasing steps
5) return the min(inc_steps, dec_steps)

"""


def increase_steps(start, end):
    inc_counter = 0
    while start != end:
        start += 1
        inc_counter += 1
        if start > 9:
            start = 0
    return inc_counter


def decrease_steps(start, end):
    dec_counter = 0
    while start != end:
        start -= 1
        dec_counter += 1
        if start < 0:
            start = 9
    return dec_counter


def increasing_or_decreasing(start, end):
    return min(increase_steps(start, end), decrease_steps(start, end))


n = int(input())
f_row = [int(x) for x in list(input())]
sec_row = [int(x) for x in list(input())]
zipped_pair = [x for x in zip(f_row, sec_row)]

counter = 0
for i in range(n):
    pair = zipped_pair[i]
    start = pair[0]
    end = pair[1]
    counter += increasing_or_decreasing(start, end)
print(counter)