#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, n1, n2, con = 0;
  string s1, s2;
  cin >> n >> s1 >> s2;
  for (int i = 0; i < n; i++) {
    n1 = s1[i] - '1' + 1;
    n2 = s2[i] - '1' + 1;
    int a = abs(n1 - n2);
    if (a > 5) a = 10 - a;
    con += a;
  }
  cout << con;
}
