#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  string s1;
  cin >> s1;
  string s2;
  cin >> s2;
  int count = 0;
  for (int i = 0; i < n; i++) {
    int a = s1[i] - '0';
    int b = s2[i] - '0';
    int temp = abs(a - b);
    temp = min(temp, 10 - temp);
    count += temp;
  }
  cout << count << "\n";
  return 0;
}
