#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, c, a[3], l;
  c = 0;
  cin >> n;
  char s1[n + 1], s2[n + 1];
  cin >> s1 >> s2;
  for (i = 0; i < n; i++) {
    a[0] = s1[i] - s2[i];
    if (a[0] < 0) a[0] = a[0] * (-1);
    a[1] = 10 - s2[i] + s1[i];
    if (a[1] < 0) a[1] = a[1] * (-1);
    a[2] = 10 - s1[i] + s2[i];
    if (a[2] < 0) a[2] = a[2] * (-1);
    l = a[0];
    for (int j = 0; j < 3; j++) {
      if (a[j] < l) l = a[j];
    }
    c = c + l;
  }
  cout << c;
}
