#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;

int n;
string s1, s2;
vector<int> n2;

int func(int x, vector<int> n1){
	if(x == n) return 0;
	if(n1[x] == n2[x]){
		return func(x+1,n1);
	}
	int ret = INF;
	vector<int> tmp = n1;
	for(int i = 0; i < n-x; i++){
		if(n1[x] > n2[x]){
			for(int j = x; j < x+i+1; j++){
				tmp[j] -= n1[x]-n2[x];
				if(tmp[j] < 0) tmp[j]+=10;
			}
			ret = min(ret,func(x+1,tmp));
		} else{
			for(int j = x; j < x+i+1; j++){
				tmp[j] += n2[x]-n1[x];
				if(tmp[j] >= 10) tmp[j]-=10;
			}
			ret = min(ret,func(x+1,tmp));
		}
		tmp = n1;
	}
	return ret+1;
}

void solve(){
	cin >> s1 >> s2;
	n2.clear();
	vector<int> n1;
	rep(i,n){
		n1.push_back(s1[i]-'0');
		n2.push_back(s2[i]-'0');
	}
	cout << func(0,n1) << endl;
}

int main(){
	while(true){
		cin >> n;
		if(n == 0) break;
		solve();
	}
}