#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s, s1;
  cin >> s >> s1;
  int fans = 0;
  for (int i = 0; i < n; i++) {
    int ans = abs((int)s[i] - (int)s1[i]) % 10;
    if (10 - ans < ans) ans = 10 - ans;
    fans += ans;
  }
  cout << fans;
  return 0;
}
