#include <bits/stdc++.h>
const int maxn = 1e5 + 100, mod = 1e9 + 7;
using namespace std;
int get_diff(int j1, int j2) {
  if (j1 > j2)
    return j1 - j2;
  else
    return j2 - j1;
}
int main() {
  int n, j1, j2, res = 0, diff;
  string ini, reqd;
  cin >> n;
  cin >> ini >> reqd;
  for (int(i) = (0); (i) < (n); ++(i)) {
    j1 = ini[i] - '0';
    j2 = reqd[i] - '0';
    diff = get_diff(j1, j2);
    if (diff < 5)
      res += diff;
    else
      res += (10 - diff);
  }
  cout << res;
  return 0;
}
