#include <bits/stdc++.h>
using namespace std;
long long dd[100009] = {0};
int main() {
  long long n;
  cin >> n;
  long long a1[n], a2[n];
  string s1, s2;
  cin >> s1 >> s2;
  for (long long i = 0; i < n; i++) {
    a1[i] = s1[i] - 48;
    a2[i] = s2[i] - 48;
  }
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    long long count = 0;
    if (abs(a1[i] - a2[i]) <= 5)
      sum += abs(a1[i] - a2[i]);
    else {
      sum += 10 - abs(a1[i] - a2[i]);
    }
  }
  cout << sum;
}
