#include <bits/stdc++.h>
using namespace std;
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
}
void file() {}
unsigned long long gcd(unsigned long long x, unsigned long long y) {
  if (y == 0) {
    return x;
  }
  return gcd(y, x % y);
}
void bitmask(string s) {
  int n = s.size();
  for (int i = 0; i < pow(2, n); i++) {
    string z;
    for (int j = 0; j < n; j++) {
      if (i & (1 << j)) {
        z += s[j];
      }
    }
    cout << z << "\n";
  }
}
set<int> ss;
int main() {
  fast();
  file();
  int n, sum = 0, m = 0, b = 0, k;
  cin >> n;
  string s, y;
  cin >> s >> y;
  for (int i = 0; i < n; i++) {
    int a = s[i] - '0';
    int a2 = y[i] - '0';
    m = abs(a - a2);
    b = (9 - a) + a2 + 1;
    k = (9 - a2) + a + 1;
    sum += min(m, min(b, k));
  }
  cout << sum << "\n";
  return 0;
}
