#include <bits/stdc++.h>
using namespace std;
int n, ans, x, y;
string second, t;
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  cin >> second;
  cin >> t;
  for (int i = 0; i < n; i++) {
    x = second[i] - 48;
    y = t[i] - 48;
    ans += min(abs(x - y), min(9 - x + y + 1, x + (10 - y)));
  }
  cout << ans << endl;
  return 0;
}
