#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s1;
  string s2;
  int mx, mn;
  int count = 0;
  cin >> s1 >> s2;
  for (int i = 0; i < n; i++) {
    mn = (int)s2[i];
    mx = (int)s1[i];
    if (s1[i] < s2[i]) {
      mn = s1[i];
      mx = s2[i];
    }
    if (abs(s1[i] - s2[i]) < abs((mn + 10) - mx)) {
      count += abs(s1[i] - s2[i]);
    } else {
      count += abs((mn + 10) - mx);
    }
  }
  cout << count << endl;
  return 0;
}
