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