#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, c = 0;
  string b, a;
  cin >> n >> b >> a;
  for (int i = 0; i < n; i++) {
    if (b[i] >= a[i]) {
      if (b[i] - a[i] <= 5)
        c = c + (b[i] - a[i]);
      else if (b[i] - a[i] == 6)
        c = c + 4;
      else if (b[i] - a[i] == 7)
        c = c + 3;
      else if (b[i] - a[i] == 8)
        c = c + 2;
      else if (b[i] - a[i] == 9)
        c++;
    } else {
      if (a[i] - b[i] <= 5)
        c = c + (a[i] - b[i]);
      else if (a[i] - b[i] == 6)
        c = c + 4;
      else if (a[i] - b[i] == 7)
        c = c + 3;
      else if (a[i] - b[i] == 8)
        c = c + 2;
      else if (a[i] - b[i] == 9)
        c++;
    }
  }
  cout << c << endl;
  return 0;
}
