#include <bits/stdc++.h>

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int f(const vector<int>& v, int i) {
  int n = v.size();
  if (i == n) return 0;
  int ml = 100;
  int k = (10 - v[i]) % 10;
  if (k == 0) return f(v, i+1);
  for (int j=i; j<n; ++j) {
    auto cp = v;
    for (int l=i; l<=j; ++l) {
      cp[l] += k;
      cp[l] %= 10;
    }
    ml = min(ml, f(cp, i+1) + 1);
  }
  return ml;
}

int main() {
  while(1){
    int n;
    cin>>n;
    if(!n) break;
    string a, b;
    cin>>a>>b;
    vector<int> v(n);
    REP(i,n) {
      v[i] = a[i] + 10 - b[i];
      v[i] %= 10;
    }
    cout << f(v, 0) << endl;
  }
  return 0;
}