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

int solve(vector<int> D, vector<int> imos, int i, int d){
  int n = D.size();
  if(i == n) return 0;
  d += imos[i];
  D[i] += 10 - d;
  D[i] %= 10;
  int ret = 1e9;
  if(D[i]){
    for(int j = i+1; j <= n; ++j){
      imos[j] -= D[i];
      ret = min(ret, 1 + solve(D,imos,i+1,(d+D[i])%10));
      imos[j] += D[i];
    }
  }else{
    ret = min(ret,solve(D,imos,i+1,d));
  }
  return ret;
}

int main(){
  int N;
  while(cin >> N, N){
    string S, T;
    cin >> S >> T;
    vector<int> D(N);
    for(int i = 0; i < N; ++i){
      D[i] = (T[i]-S[i]+10)%10;
    }
    cout << solve(D,vector<int>(N+1,0),0,0) << endl;
  }
  return 0;
}

