#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sum = 0;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;
  for (size_t i = 0; i < n; i++) {
    if (s1[i] < s2[i])
      sum += min(s1[i] - s2[i] + 10, s2[i] - s1[i]);
    else
      sum += min(s1[i] - s2[i], s2[i] - s1[i] + 10);
  }
  cout << sum;
}
