#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s1;
  string s2;
  string sd;
  cin >> s1;
  cin >> s2;
  long long ans = 0;
  for (int i = 0; i < s1.length(); i++) {
    int a = s1[i] - '0';
    int b = s2[i] - '0';
    ans += min(abs(a - b), (9 - (max(a, b)) + (min(a, b) - 0) + 1));
  }
  cout << ans << endl;
}
