#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, temp1, temp2;
  scanf("%d", &n);
  char a[n + 1], b[n + 1];
  scanf("%s%s", a, b);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    temp1 = a[i] % 48;
    temp2 = b[i] % 48;
    if (temp1 > temp2) swap(temp1, temp2);
    if ((temp2 - temp1) > 5) {
      sum = sum + temp1 + 10 - temp2;
    } else
      sum = sum + temp2 - temp1;
  }
  printf("%d", sum);
  return 0;
}
