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