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.
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define GCD(x, y) __gcd(x, y)
#define LCM(x, y) (x*y)/GCD(x, y)
#define pb push_back
#define eb emplace_back

const ll INF = 1e16;

ll ceilDiv(ll x, ll y){
    return x/y + (x % y != 0);
}

template <typename T>
void ptVec(vector<T> &vec){
    for (const T i : vec){ cout << i << " "; }
    cout << endl;
}

template <typename T>
void ptArr(T *a, ll n) {
    for (int i = 0; i < n; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}

bool isPrime(ll n){
    bool prime = true;
    for (int i = 2; i*i <= n; i++){ if (n % i == 0){ prime = false; break; } }
    return n != 1 && prime;
}

vector<bool> primes(1e1 + 1, true);
void sieve(ll n){
    primes[0] = false, primes[1] = false;
    for (ll i = 2; i*i < n; i++){ if (primes[i]){ for (ll j = i*i; j < n; j += i){ primes[j] = false; } } }
}

// auto primeFacIt = primeFacs.begin();
// map<ll, ll> primeFacs;
map<ll, ll> primeFactors(ll n)
{
    map<ll, ll> primeFacs;
    while (n % 2 == 0){
        primeFacs[2]++;
        n = n/2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2){
        while (n % i == 0)
        {
            primeFacs[i]++;
            n = n/i;
        }
    }
    if (n > 2){
        primeFacs[n]++;
    }

    return primeFacs;
}


void solve(){
    ll n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;

    ll ans = 0;
    for (int i = 0; i < n; i++){
        ans += min({abs(s1[i] - s2[i]), s1[i] - s2[i] + 10, s2[i] - s1[i] + 10});
    }

    cout << ans << endl;
}

int main() {

    /*
    ll t;
    cin >> t;
    while (t--){
        solve();
    }
     */

    solve();

    return 0;
}
