#include <bits/stdc++.h>
using namespace std;
int abs(int a) {
  if (a >= 0) return a;
  return -a;
}
int min(int a, int b) {
  if (a > b) return b;
  return a;
}
int main() {
  int n;
  cin >> n;
  char a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  char b[n];
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += min(abs(a[i] - b[i]), 10 - abs(a[i] - b[i]));
  }
  cout << ans;
  return 0;
}
