#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char str1[100000], str2[1000000];
  int sum = 0;
  int i, j;
  for (i = 0; i < n; i++) {
    cin >> str1[i];
  }
  for (i = 0; i < n; i++) {
    cin >> str2[i];
  }
  for (i = 0; i < n; i++) {
    int con1 = 0, con2 = 0;
    j = str1[i] - 48;
    while (true) {
      if (j == str2[i] - 48) break;
      j++;
      con1++;
      j %= 10;
    }
    j = str1[i] - 48;
    while (true) {
      if (j == 0 && str2[i] != '0') {
        con2++;
        j = 9;
      }
      if (j == str2[i] - 48) break;
      j--;
      con2++;
    }
    if (con1 >= con2) {
      sum += con2;
    } else {
      sum += con1;
    }
  }
  cout << sum << endl;
}
