#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

#define whole(xs) (xs).begin(),(xs).end()
#define uniq(xs) ((xs).erase(unique((xs).begin(), (xs).end()), (xs).end()))

int N;
string s, t;

bool input() {
    cin >> N;
    if (N == 0) return false;
    cin >> s >> t;
    return true;
}

const int INF = 20;

int dfs(int index, vector<int>& ds) {
    if (index == N) return 0;
    int ret = INF;
    int d = ds[index];
    if (d == 0) { return dfs(index + 1, ds); }
    vector<int> backup = ds;
    for (int i = index; i < N; i++) {
        ds[i] = (ds[i] + 10 - d) % 10;
        ret = min(ret, dfs(index + 1, ds) + 1);
    }
    ds = backup;
    return ret;
}

void solve() {
    vector<int> ds;
    for (int i = 0; i < N; i++) {
        int a = int(s[i] - '0');
        int b = int(t[i] - '0');
        ds.push_back( (a + 10 - b) % 10 );
    }
    cout << dfs(0, ds) << endl;
}

int main() {
    while (input()) solve();
    return 0;
}