#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, sum = 0;
  cin >> n;
  char ar1[n], ar2[n];
  cin >> ar1;
  cin >> ar2;
  for (int i = 0; i < n; i++) {
    a = abs(ar1[i] - ar2[i]);
    b = 10 - a;
    if (a > b)
      sum = sum + b;
    else
      sum = sum + a;
  }
  cout << sum;
}
