#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long n;
  cin >> n;
  string a, b;
  cin >> a >> b;
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    long long digit1 = a[i] - '0';
    long long digit2 = b[i] - '0';
    ans += min(abs(digit2 - digit1),
               min(9 - digit1 + digit2 + 1, 9 - digit2 + digit1 + 1));
  }
  cout << ans << endl;
}
