#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, s, c, c1, c2, or1, or2, ps1, ps2;
  cin >> n;
  char org[n], pass[n];
  for (i = 0; i < n; i++) {
    cin >> org[i];
  }
  for (i = 0; i < n; i++) {
    cin >> pass[i];
  }
  s = 0;
  for (i = 0; i < n; i++) {
    or1 = org[i] - 48;
    ps1 = pass[i] - 48;
    c1 = 0;
    while (or1 != ps1) {
      or1++;
      c1++;
      if (or1 == 10) or1 = 0;
    }
    c2 = 0;
    or2 = org[i] - 48;
    ps2 = pass[i] - 48;
    while (or2 != ps2) {
      or2--;
      c2++;
      if (or2 == -1) or2 = 9;
    }
    if (c1 > c2)
      c = c2;
    else
      c = c1;
    s += c;
  }
  cout << s << endl;
  return 0;
}
