#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ans = 0;
  cin >> n;
  char a[1050], b[1050];
  cin >> a >> b;
  for (int i = 0; i < n; i++) {
    char mn = min(a[i], b[i]);
    char mx = max(a[i], b[i]);
    ans += min(mx - mn, '9' - mx + mn + 1 - '0');
  }
  cout << ans;
}
