#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m, i, j, k, x, y, z, ans = 0;
  string s, s1;
  bool flag;
  cin >> n;
  cin.ignore();
  cin >> s >> s1;
  for (i = 0; i < n; i++) {
    s[i] = 48 - s[i];
    s1[i] = 48 - s1[i];
    j = abs(s[i] - s1[i]);
    k = 10 - max(s[i], s1[i]) + min(s[i], s1[i]);
    ans += min(j, k);
  }
  cout << ans << endl;
}
