#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, sum = 0, first = 0, second = 0, count = 0, temp, rat, diff1,
                   diff2;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;
  for (int i = 0; i < s1.length(); i++) {
    first = s1[i] - 48;
    second = s2[i] - 48;
    if (first > second) {
      temp = second;
      second = first;
      first = temp;
    }
    diff1 = abs(first - second);
    diff2 = (9 - second + first + 1);
    if (diff2 > 9) {
      diff2 = diff2 % 9;
    }
    if (diff1 > diff2) {
      sum += diff2;
    } else {
      sum += diff1;
    }
  }
  cout << sum;
  return 0;
}
