#include<bits/stdc++.h>
/*
*/

using namespace std;


int solve( vector<int>D, int idx ) {
	if( idx == D.size() ) {
		return 0;
	}
	if( D[idx] == 0 ) {
		return solve( D, idx + 1 );
	}
	int now = D[idx];
	int ret = INT_MAX;
	for( size_t i = idx; i < D.size(); i++ ) {
		D[i] -= now;
		if( D[i] < 0 ) {
			D[i] += 10;
		}
		ret = min( ret, solve( D, idx + 1 ) + 1 );
	}
	return ret;
}

int main() {

	long long int N;
	while( cin >> N, N ) {
		string A, B;
		cin >> A >> B;
		vector<int>D( N );
		for( size_t i = 0; i < N; i++ ) {
			D[i] = A[i] - B[i];
			if( D[i] < 0 ) {
				D[i] += 10;
			}
		}

		cout << solve( D, 0 ) << endl;
	}
}