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