#include <bits/stdc++.h>
using namespace std;
string s2, s1;
int a[1001], b[1001];
long long n, i, t, t1, ma, s;
int main() {
  cin >> n;
  cin >> s2;
  cin >> s1;
  for (i = 1; i <= n; i++) a[i] = s2[i - 1] - '0';
  for (i = 1; i <= n; i++) b[i] = s1[i - 1] - '0';
  t = 0;
  s = 0;
  for (i = 1; i <= n; i++) {
    if (a[i] < b[i])
      t = a[i] + 1 + 9 - b[i];
    else
      t = b[i] + 1 + 9 - a[i];
    t1 = b[i] - a[i];
    if (t1 < 0) t1 *= -1;
    if (t < t1)
      s += t;
    else
      s += t1;
  }
  cout << s;
}
