#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string org;
  string pre;
  cin >> org;
  cin >> pre;
  int i;
  long int ans = 0;
  for (i = 0; i < org.length(); i++) {
    int t = ((int)org[i]) - 48;
    int m = ((int)pre[i]) - 48;
    int ans1 = 0, ans2 = 0;
    if (t > m) {
      ans1 = t - m;
      ans2 = m - t + 10;
    } else if (m > t) {
      ans1 = m - t;
      ans2 = t - m + 10;
    }
    ans = ans + min(ans1, ans2);
  }
  cout << ans << endl;
  return 0;
}
