#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sum = 0;
  string s, t;
  cin >> n >> s >> t;
  for (int i = 0; i < n; i++) {
    if (s[i] > t[i]) {
      sum += min(s[i] - t[i], t[i] + 10 - s[i]);
    } else {
      sum += min(t[i] - s[i], s[i] + 10 - t[i]);
    }
  }
  cout << sum << endl;
  return 0;
}
