#include <bits/stdc++.h>
using namespace std;
const int row = 101;
int arr[row];
inline long long gcd(long long a, long long b) {
  if (a > b) swap(a, b);
  if (a == 0)
    return b;
  else
    return gcd(a, b % a);
}
int main() {
  string str1, str2;
  int n, c1 = 0;
  cin >> n >> str1 >> str2;
  for (int i = 0; i < n; i++) {
    char ch1 = str1.at(i), ch2 = str2.at(i);
    c1 += min(((ch1 - ch2 + 10) % 10), ((ch2 - ch1 + 10) % 10));
  }
  cout << c1 << endl;
  return 0;
}
