#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, arr1[1000], arr2[1000], s, r, sum = 0;
  string a, b;
  cin >> n >> a >> b;
  for (int i = 0; i < n; i++) {
    arr1[i] = a[i] - '0';
    arr2[i] = b[i] - '0';
  }
  for (int i = 0; i < n; i++) {
    if (arr1[i] > arr2[i]) {
      s = 10 - arr1[i] + arr2[i];
      r = arr1[i] - arr2[i];
      if (s > r)
        sum += r;
      else
        sum += s;
    } else if (arr2[i] > arr1[i]) {
      s = 10 - arr2[i] + arr1[i];
      r = arr2[i] - arr1[i];
      if (s > r)
        sum += r;
      else
        sum += s;
    } else
      sum += 0;
  }
  cout << sum << endl;
  return 0;
}
