#include <bits/stdc++.h>
using namespace std;
int main() {
  int sum;
  int n;
  string s1, s2;
  while (cin >> n) {
    cin >> s1 >> s2;
    sum = 0;
    for (int i = 0; i < n; i++) {
      int k1 = s1[i] - '0';
      int k2 = s2[i] - '0';
      int k3 = abs(k1 - k2);
      if (k3 > 5) {
        sum += 10 - k3;
      } else {
        sum += k3;
      }
    }
    cout << sum << endl;
  }
  return 0;
}
