#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr1[1005], arr2[1005];
  string s1, s2;
  cin >> s1 >> s2;
  for (int i = 1; i <= n; i++) arr1[i] = s1[i - 1] - '0';
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    arr2[i] = s2[i - 1] - '0';
    ans += min(abs(arr2[i] - arr1[i]), 10 - abs(arr2[i] - arr1[i]));
  }
  cout << ans;
  return 0;
}
