#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 < n; i++) {
    int sel = abs(a[i] - b[i]);
    if (sel > 5) sel = 10 - sel;
    ans += sel;
  }
  cout << ans << endl;
}
