#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, i;
  char s[1100], y[1100];
  while (cin >> a) {
    int sum;
    getchar();
    cin >> s >> y;
    for (sum = 0, i = 0; i < a; i++) {
      if (s[i] > y[i]) swap(s[i], y[i]);
      sum += min(y[i] - s[i], 10 - y[i] + s[i]);
    }
    cout << sum << endl;
  }
}
