#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[1001], b[1001];
  int n, m, i, t;
  cin >> n >> a >> b;
  t = 0;
  for (i = 0; i < n; i++) {
    m = abs(a[i] - b[i]);
    if (m > 5) m = 10 - m;
    t = t + m;
  }
  cout << t;
}
