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