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

const int INF = 1<<28;
int N;
string A, B;

int rec(vector<int> v) {
  if(v.empty()) return 0;
  if(v[0] == 0) {
    return rec(vector<int>(v.begin()+1, v.end()));
  }
  int d = -v[0];
  int res = INF;
  for(int i = 0; i < v.size(); ++i) {
    v[i] = (v[i] + d + 10) % 10;
    res = min(res, rec(vector<int>(v.begin()+1, v.end())) + 1);
  }
  return res;
}

int main() {
  while(cin >> N && N) {
    cin >> A >> B;
    vector<int> v(N);
    for(int i = 0; i < N; ++i) {
      v[i] = (B[i] - A[i] + 10) % 10;
    }
    cout << rec(v) << endl;
  }
  return 0;
}