#include <bits/stdc++.h>
using namespace std;
bool isSimple(int n, int k) {
  if (n % k == 0) {
    return false;
  } else if (k == n / 2) {
    return true;
  } else {
    return isSimple(n, k + 1);
  }
}
template <typename G>
void mySwap(G& a, G& b) {
  G temp = a;
  a = b;
  b = temp;
}
string decToBin(string str) {
  int b;
  string word;
  b = stoi(str);
  while (b != 0) {
    word += char('0' + (b % 2));
    b = b / 2;
  }
  for (int i = 0; i < word.size() / 2; i++) {
    mySwap(word[i], word[word.size() - 1 - i]);
  }
  return word;
}
int main() {
  int n, count = 0;
  cin >> n;
  string future, current;
  cin >> current >> future;
  char number, number2;
  for (int i = 0; i < n; i++) {
    number = current[i];
    number2 = future[i];
    count += min(abs(number2 - number),
                 abs(min(number2, number) + 10 - max(number, number2)));
  }
  cout << count;
  return 0;
}
