#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, a, b, s = 0;
  char s1[10001], s2[10001];
  cin >> n;
  cin.ignore(10000, '\n');
  cin.get(s1, 10001, '\n');
  cin.ignore(10000, '\n');
  cin.get(s2, 10001, '\n');
  cin.ignore(10000, '\n');
  for (i = 0; i < n; ++i) {
    if (s1[i] - 48 > s2[i] - 48)
      a = (10 - (s1[i] - 48)) + (s2[i] - 48);
    else
      a = (10 - (s2[i] - 48)) + (s1[i] - 48);
    if (s1[i] - 48 > s2[i] - 48)
      b = (s1[i] - 48) - (s2[i] - 48);
    else
      b = (s2[i] - 48) - (s1[i] - 48);
    if (a > b)
      s += b;
    else
      s += a;
  }
  cout << s;
  return 0;
}
