#include <bits/stdc++.h>
using namespace std;
int n, z, w, k, p, m;
string x, y;
int main() {
  cin >> n >> x >> y;
  for (int i = 0; i < n; i++) {
    z = x[i] - 48;
    p = y[i] - 48;
    m = z - p;
    if (x[i] > y[i]) {
      w = 1 + y[i] + 9 - x[i];
    } else {
      w = 1 + x[i] + 9 - y[i];
    }
    if (m < 0) {
      m *= -1;
    }
    if (m < w) {
      k = m + k;
    } else {
      k = w + k;
    }
  }
  cout << k;
}
