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