#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d, k, n, m, x, y, z, ans, cnt, tt;
long long mx = -1e6, lx = 1e6, lx1 = 1e6, lx2 = 1e6;
char h, h1, h2, h3;
string s, s1, s2, s3, g, g1, g2, g3;
vector<string> v, q, t;
map<long long, long long> mp;
int main() {
  cin >> a >> s >> g;
  for (long long i = 0; i < s.size(); i++) {
    int a = s[i] - 48;
    int b = g[i] - 48;
    c = abs(a - b);
    if (c <= 5) {
      d += c;
    } else if (c == 6)
      d += 4;
    else if (c == 7)
      d += 3;
    else if (c == 8)
      d += 2;
    else if (c == 9)
      d += 1;
  }
  cout << d;
}
