#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, x, y, c = 0;
  scanf("%d", &n);
  char s1[n], s2[n];
  scanf("%s", s1);
  scanf("%s", s2);
  for (i = 0; i < n; i++) {
    x = max(s1[i], s2[i]);
    y = min(s1[i], s2[i]);
    if (x - y <= 5) {
      c = c + x - y;
    } else
      c = c + 56 - x + y - 47 + 1;
  }
  printf("%d\n", c);
  return 0;
}
