#include <bits/stdc++.h>
using namespace std;
int ans;
int main() {
  int n;
  string s, s1;
  cin >> n >> s >> s1;
  for (int i = 0; i < n; i++) {
    int ans1 = min(abs(s1[i] - s[i]), abs('9' - s[i]) + (s1[i] - '0') + 1);
    ans1 = min(ans1, abs((s[i] - '0') + ('9' - s1[i])) + 1);
    ans += ans1;
  }
  cout << ans;
  return 0;
}
