#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);++i)
#define rep(i,n) REP(i, 0, n)
int K;
int dfs(const vector<int>& a, int d, int pos) {
    if(pos == K) return d;
    if(a[pos] == 0) return dfs(a, d, pos + 1);
    int res = INF;
    vector<int> temp = a;
    REP(i, pos, K) {
        temp[i] -= a[pos];
        if(temp[i] < 0) temp[i] += 10;
        res = min(res, dfs(temp, d + 1, pos + 1));
    }
    return res;
}
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    while(cin >> K && K) {
        string s1, s2; cin >> s1 >> s2;
        vector<int> a(K);
        rep(i, K) a[i] = (int)(s2[i] - s1[i]);
        for(int& k : a) if(k < 0) k += 10;
        cout << dfs(a, 0, 0) << endl;
    }
    return 0;
}