#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, s(0);
  char s1[10001], s2[10001];
  cin >> n;
  cin.ignore(100000, '\n');
  cin.get(s1, 10001, '\n');
  cin.ignore(100000, '\n');
  cin.get(s2, 10001, '\n');
  cin.ignore(100000, '\n');
  for (int i = 0; i < n; ++i) {
    s += min(abs((s1[i] - 48) - (s2[i] - 48)),
             10 - abs((s1[i] - 48) - (s2[i] - 48)));
  }
  cout << s;
  return 0;
}
