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.

 [Image] 

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?


-----Input-----

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.


-----Output-----

Print a single integer — the minimum number of moves Scrooge McDuck needs to open the lock.


-----Examples-----
Input
5
82195
64723

Output
13



-----Note-----

In the sample he needs 13 moves:

  1 disk: $8 \rightarrow 7 \rightarrow 6$  2 disk: $2 \rightarrow 3 \rightarrow 4$  3 disk: $1 \rightarrow 0 \rightarrow 9 \rightarrow 8 \rightarrow 7$  4 disk: $9 \rightarrow 0 \rightarrow 1 \rightarrow 2$  5 disk: $5 \rightarrow 4 \rightarrow 3$

Difficulty: interview

Starter code:

Solutions:
n = int(input())

s = input()
code = input()

res = 0
for i in range(n):
    k = abs(int(s[i]) - int(code[i]))
    res += min(k, 10 - k)

print(res)

n = int(input())
string1 = input()
string2 = input()
answer = 0
for i in range(n):
    answer += min(abs(int(string1[i]) - int(string2[i])), 10 - abs(int(string1[i]) - int(string2[i])))
print(answer)

l = int(input())
s1 = list(map(int, input().replace('', ' ').split()))
s2 = list(map(int, input().replace('', ' ').split()))
res = 0
for i in range(l):
    res += min(abs(s1[i] - s2[i]), 10 - abs(s1[i] - s2[i]))
print(res)


import sys

def get_d(d1, d2):
    if d1 > d2:
        d1, d2 = d2, d1
    return min(d2 - d1, 10 - d2 + d1)

#fin = open("input.txt", 'r')
fin = sys.stdin

n = int(fin.readline())
s1 = fin.readline().strip()
s2 = fin.readline().strip()
ans = 0
for i in range(n):
    ans += get_d(int(s1[i]), int(s2[i]))
print(ans)

def solve(n, m):
    return min(abs(n-m), abs(10+n-m), abs(10+m-n))

n = int(input())
S = input()
T = input()
ans = 0
for s, t in zip(S, T):
    ans += solve(int(s), int(t))
print(ans)


n = int(input())
s = input()
t = input()
ans = 0
for i in range(n):
    a = int(s[i])
    b = int(t[i])
    if a >= b:
        ans += min(a - b, 10 + b - a)
    else:
        ans += min(b - a, 10 + a - b)
print(ans)


n = int(input())
a = input()
b = input()

def cnt(a, b):
    a, b = int(a), int(b)
    a, b = min(a,b), max(a,b)
    return min(b-a, a+10-b)

ans = 0
for i in range(n):
    ans += cnt(a[i], b[i])

print(ans)


def diff(a, b):
    return min((int(a) - int(b) + 10) % 10, (int(b) - int(a) + 10) % 10)

def __starting_point():
    n = int(input())
    total = 0
    source = input()
    target = input()
    for i in range(len(source)):
        total += diff(source[i], target[i])
    print(total)

__starting_point()

n = int(input())
start = input()
goal = input()

count = 0
for s, g in zip(start, goal):
    s = int(s)
    g = int(g)
    count += min(abs(s-g), abs(10 + s - g), abs(10 + g - s))
print(count)


def f1(a,b):
    return abs(a-b)

def f2(a,b):
    a, b = max(a,b), min(a,b)
    b += 10
    return b-a

n = int(input())
a = [int(x) for x in list(input())]
b = [int(x) for x in list(input())]


print(sum(min(f1(x,y),f2(x,y)) for x,y in zip(a,b)))



def main():
    n = int(input())
    b = input()
    a = input()
    ans = 0
    for i in range(n):
        ans += min(abs(int(b[i])-int(a[i])), 10-abs(int(b[i])-int(a[i])))
    print(ans)


def __starting_point():
    main()

__starting_point()

N = int(input())
S1 = input()
S2 = input()

def move(a, b):
    return min(max(a,b)-min(a,b), min(a,b)+10-max(a,b))

ans = 0
for i in range(N):
    ans += move(int(S1[i]),int(S2[i]))

print(ans)


n = int(input())
s = [int(k) for k in input()]
s2 = [int(k) for k in input()]
t = 0
for i in range(n):
    t+=min((s[i]-s2[i])%10, (10-(s[i]-s2[i]))%10)
print(t)


n = int(input())
num = input()
num2 = input()
num3 = 0
for i in range(n):
    temp = abs(int(num[i]) - int(num2[i])) 
    num3 += min(temp,10 - temp)
print(num3)


n = int(input())
a1 = input().strip()
a2 = input().strip()
res = 0
for i in range(n):
	symbA1 = int(a1[i])
	symbA2 = int(a2[i])
	res += min(abs(symbA2-symbA1), abs(min(symbA2,symbA1) + 10 - max(symbA1, symbA2)))
print(res)

n = int(input())
s1 = [int(x) for x in input()]
s2 = [int(x) for x in input()]

def min(a, b):
	if a < b:
		return a
	else:
		return b

ans = 0
for i in range(n):
	abso = abs(s1[i] - s2[i])
	ans += min(abso, 10 - abso)
	
print(ans)

import sys
from math import *
#sys.stdin = open('inp', 'r')
n = int(input())
a, b = input(), input()
ans = 0
for i in range(n):
    cur = int(a[i])
    ok = int(b[i])
    cnt1 = 0
    cnt2 = 0
    while cur != ok:
        cur = (cur + 1) % 10
        cnt1 += 1
    cur = int(a[i])
    while cur != ok:
        if cur == 0:
            cur = 9
        else:
            cur -= 1
        cnt2 += 1
    ans += min(cnt1, cnt2)
print(ans)




n = int(input())

a, b = input(), input()

s = 0

for i in range(n):
	tmp = ord(a[i]) - ord(b[i])
	tmp %= 10
	if tmp > 5:
		s += 10 - tmp
	else:
		s += tmp

print(s)


import math



n=int(input())
s1=input()
s2=input()

l=len(s1)
svar=0
for i in range(0,l):
    x=abs(int(s1[i])-int(s2[i]))
    y=abs(10-int(s1[i])+int(s2[i]))
    z=abs(int(s1[i])+10-int(s2[i]))
    svar+=min(x,y,z)
print(svar)

    


n=int(input())
s1=input().strip()
s2=input().strip()
ans=0
for i in range(n):
    a, b = int(s1[i]), int(s2[i])
    if a > b:
        a, b=b, a
    ans+=min(b-a, 9-b+a+1)
print(ans)

n = int(input())
a1 = input()
a2 = input()
sm = 0
for i in range(n):
    q = int(a1[i])
    w = int(a2[i])
    sm += min(abs(q - w), min(q, w) + 10 - max(q, w))
print(sm)

def turns(n,x,y):
	c = 0
	for i in range(n):
		a = abs(int(x[i])-int(y[i]))
		if(a > 5):
			a = 10 - a
		c += a
	return c


n = int(input())
x = input()
y = input()

print(turns(n,x,y))

z = list(map(int, input().split()))
n= z[0]
inp  = list(input())
out = list(input())
ans = 0
for i in range(n):
    if abs(int(inp[i]) - int(out[i])) > 5:
        ans += 10 -abs(int(inp[i]) - int(out[i]))
    else:
        ans+=abs(int(inp[i]) - int(out[i]))
        
print(ans)

n = int(input())
a = input()
b = input()
ans = 0
for i in range(len(a)):
    x = int(a[i])
    y = int(b[i])
    ans += min(abs(y - x), min(10 + x - y, 10 + y - x))
print(ans)

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n = int(input())

code_old = input()
code_new = input()

steps = 0

for i in range(n):
    steps_i = abs(int(code_new[i]) - int(code_old[i]))
    if steps_i > 5:
        steps_i = 10 - steps_i
    steps += steps_i

print(steps)