#include <bits/stdc++.h>
using namespace std;
long long freq[10000], freq1[10000];
int main() {
  long long n;
  cin >> n;
  string s;
  string a;
  cin >> s >> a;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += min(fabs(s[i] - a[i]), 10 - fabs(s[i] - a[i]));
  }
  cout << ans;
  return 0;
}
