#include <bits/stdc++.h>
using namespace std;
int main() {
  char ch[10000], bh[10000];
  long i, j, a, b, n, m1, m2, mov;
  cin >> n;
  for (i = 0; i < n; i++) cin >> ch[i];
  for (j = 0; j < n; j++) cin >> bh[j];
  mov = 0;
  for (i = 0; i < n; i++) {
    a = ch[i] - '0';
    b = bh[i] - '0';
    if (a < b) {
      m1 = b - a;
      m2 = a + (9 - b) + 1;
      mov += min(m1, m2);
    } else {
      m1 = b + (9 - a) + 1;
      m2 = a - b;
      mov += min(m1, m2);
    }
  }
  cout << mov << endl;
  return 0;
}
