#include <bits/stdc++.h>
using namespace std;
void c1(long y) {
  if (y == 0) return;
  c1((y - 1) / 26);
  (cout << ((char)('A' + (y - 1) % 26)));
}
int main() {
  int n, x, res = 0;
  string p, q;
  (cin >> n);
  ;
  (cin >> p);
  ;
  (cin >> q);
  ;
  for (auto i = (0); i < (n); i++) {
    x = abs(p[i] - q[i]);
    res += min(x, 10 - x);
  }
  (cout << (res) << endl);
  return 0;
}
