#include <bits/stdc++.h>
int main() {
  int n, j = 0, i, p, q, r;
  char a[10000], b[10000];
  scanf("%d", &n);
  scanf("%s", a);
  scanf("%s", b);
  for (i = 0; i < n; i++) {
    q = a[i];
    r = b[i];
    p = abs(q - r);
    j += (p > (10 - p)) ? (10 - p) : p;
  }
  printf("%d", j);
  return 0;
}
