#include <bits/stdc++.h>
using namespace std;
int n, ans;
string s1, s2;
int main() {
  cin >> n;
  cin >> s1 >> s2;
  int a, b;
  for (int i = 0; i < n; i++) {
    a = s1[i] - '0';
    b = s2[i] - '0';
    if (a > b) {
      ans += min(a - b, b + 10 - a);
    } else {
      ans += min(b - a, a + 10 - b);
    }
  }
  cout << ans << "\n";
}
