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