#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sum = 0;
  scanf("%d", &n);
  char str[n], str2[n];
  cin >> str;
  cin >> str2;
  int a[n], b[n];
  for (int i = 0; i < n; i++) a[i] = (int)str[i] - 48;
  for (int i = 0; i < n; i++) b[i] = (int)str2[i] - 48;
  for (int i = 0; i < n; i++) {
    if (abs(a[i] - b[i]) > 5) {
      if (a[i] == 0 && b[i] == 9 || a[i] == 9 && b[i] == 0)
        sum += 1;
      else if (a[i] == 0 && b[i] == 8 || a[i] == 8 && b[i] == 0)
        sum += 2;
      else if (a[i] == 0 && b[i] == 7 || a[i] == 7 && b[i] == 0)
        sum += 3;
      else if (a[i] == 0 && b[i] == 6 || a[i] == 6 && b[i] == 0)
        sum += 4;
      else if (a[i] == 1 && b[i] == 9 || a[i] == 9 && b[i] == 1)
        sum += 2;
      else if (a[i] == 1 && b[i] == 8 || a[i] == 8 && b[i] == 1)
        sum += 3;
      else if (a[i] == 1 && b[i] == 7 || a[i] == 7 && b[i] == 1)
        sum += 4;
      else if (a[i] == 2 && b[i] == 9 || a[i] == 9 && b[i] == 2)
        sum += 3;
      else if (a[i] == 2 && b[i] == 8 || a[i] == 8 && b[i] == 2)
        sum += 4;
      else
        sum += 4;
    } else
      sum += abs(a[i] - b[i]);
  }
  printf("%d", sum);
  return 0;
}
