#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j;
  string k, l;
  int a, b, sum = 0;
  scanf("%d", &n);
  cin >> k;
  cin >> l;
  for (i = 0; i <= n - 1; i++) {
    a = k[i] - l[i];
    if (a < 0) a = a + 10;
    b = l[i] - k[i];
    if (b < 0) b = b + 10;
    sum += min(a, b);
  }
  printf("%d", sum);
  return 0;
}
