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