#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  getchar();
  int have[1000];
  for (int i = 0; i < N; i++) have[i] = getchar() - '0';
  getchar();
  int need[1000];
  for (int i = 0; i < N; i++) need[i] = getchar() - '0';
  getchar();
  int x = 0;
  for (int i = 0; i < N; i++) {
    int M = max(have[i], need[i]);
    int m = min(have[i], need[i]);
    x += min(M - m, m - M + 10);
  }
  cout << x << endl;
  return 0;
}
