#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, y, z = 0, i, j, k, l, m;
  char a[1005], b[1005];
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n; i++) {
    cin >> b[i];
    x = abs(a[i] - b[i]);
    if (x <= 5)
      z += x;
    else {
      y = 9 - max(a[i], b[i]) + min(a[i], b[i]) + 1;
      z += y;
    }
  }
  cout << z << endl;
  return 0;
}
