#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, l, s, m, a, b, c;
  cin >> n;
  string s1, s2;
  cin >> s1;
  cin >> s2;
  int p, q;
  n = s1.size();
  n = s2.size();
  int cot = 0;
  for (int i = 0; i < s1.size(); i++) {
    if (s1[i] > s2[i]) {
      a = abs(s2[i] - s1[i]);
      b = s2[i] + 10;
      c = b - s1[i];
      if (c < a) {
        cot = cot + c;
      } else {
        cot = cot + a;
      }
    } else {
      k = abs(s1[i] - s2[i]);
      l = s1[i] + 10;
      m = l - s2[i];
      if (m < k) {
        cot = cot + m;
      } else {
        cot = cot + k;
      }
    }
  }
  cout << cot << endl;
}
