#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, c;
  int n, t = 0;
  cin >> n;
  cin >> s >> c;
  for (int i = 0; i < n; i++) {
    int p = s[i], k = c[i];
    if (p <= k)
      t += min(abs(p - k), (p + 1) + (9 - k));
    else
      t += min((9 - p) + (k + 1), abs(p - k));
  }
  cout << t << endl;
}
