#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  string s1;
  string s2;
  cin >> s1 >> s2;
  long long int count = 0;
  for (long long int i = 0; i < n; i++) {
    long long int a;
    a = abs(s1.at(i) - s2.at(i));
    if (a > 4) {
      int q = 9 - a + 1;
      count += q;
    } else
      count += a;
  }
  cout << count;
}
