#include <bits/stdc++.h>
int main(void) {
  char array[1005], ch[1005];
  int i, n, sum, prod;
  scanf("%d", &n);
  getchar();
  gets(array);
  gets(ch);
  sum = 0;
  prod = 0;
  for (i = 0; i < n; i++) {
    if ((abs(array[i] - ch[i])) > 5) {
      sum = sum + (10 - (abs(array[i] - ch[i])));
    } else {
      prod = prod + (abs(array[i] - ch[i]));
    }
  }
  printf("%d\n", sum + prod);
  return 0;
}
