#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, mn = 0, x, y, z;
  cin >> n;
  string s, p;
  long long int i, c = 0;
  cin >> s >> p;
  for (i = 0; i < n; i++) {
    x = abs(s[i] - p[i]);
    y = abs(s[i] + 10 - p[i]);
    z = abs(p[i] + 10 - s[i]);
    mn = min(z, min(x, y));
    c += mn;
  }
  cout << c << endl;
  return 0;
}
