#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string original;
  cin >> original;
  string passw;
  cin >> passw;
  int ans = 0;
  for (int i = 0; i < passw.size(); i++) {
    int x = original[i] - '0';
    int y = passw[i] - '0';
    if (x >= y)
      ans += min(x - y, 10 - abs(x - y));
    else
      ans += min(y - x, 10 - abs(x - y));
  }
  cout << ans << endl;
  return 0;
}
