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