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