#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, arr[200000], arrr[200000], c = 0;
  string x;
  cin >> n;
  cin >> x;
  for (int i = 0; i < n; i++) {
    arr[i] = (int)x[i];
  }
  cin >> x;
  for (int i = 0; i < n; i++) {
    arrr[i] = (int)x[i];
  }
  for (int i = 0; i < n; i++) {
    if (abs(arr[i] - arrr[i]) < 5) {
      c += abs(arr[i] - arrr[i]);
    } else if (abs(arr[i] - arrr[i]) == 0) {
      c += 0;
    } else {
      c += 10 - abs(arr[i] - arrr[i]);
    }
  }
  cout << c;
  return 0;
}
