#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string a, b;
  cin >> a >> b;
  int i, c = 0;
  for (i = 0; i < n; i++) {
    c += min(abs(a[i] - b[i]), 10 - abs(a[i] - b[i]));
  }
  cout << c;
}
