#include <bits/stdc++.h>
using namespace std;
int main() {
  string CurrState, Combination;
  int col, rot = 0;
  cin >> col >> CurrState >> Combination;
  for (int i = 0; i < col; i++) {
    int a, b;
    a = abs(CurrState[i] - Combination[i]);
    b = 10 - ((CurrState[i] > Combination[i]) ? CurrState[i] : Combination[i]) +
        ((CurrState[i] < Combination[i]) ? CurrState[i] : Combination[i]);
    rot += ((a < b) ? a : b);
  }
  cout << endl << rot;
  return 0;
}
