#include <bits/stdc++.h>
using namespace std;
const int INF = (-1u) / 2;
const long long int INF2 = (-1ull) / 2;
int a, b, i, d[1011000], j, k, n, m, timer = 0, l, r, x, y;
int c[1011000], cnt = 0, fl = 0, a2, a3 = -1000000, ans = 0;
string s, ss;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  cin >> s >> ss;
  for (i = 0; i < n; i++) {
    a = s[i] - '0';
    b = ss[i] - '0';
    fl = abs(a - b);
    fl = min(fl, min(a, b) + 9 - max(a, b) + 1);
    ans += fl;
  }
  cout << ans << endl;
  return 0;
}
