#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k, n, ans = 0;
  char c[1004], d[1004];
  cin >> n;
  cin >> c;
  cin >> d;
  for (i = 0; i < n; i++) {
    if (c[i] > d[i]) {
      int y;
      y = c[i] - d[i];
      int z;
      z = 10 - y;
      if (y < z) {
        ans = ans + y;
      } else {
        ans = ans + z;
      }
    } else {
      int y;
      y = d[i] - c[i];
      int z;
      z = 10 - y;
      if (y < z) {
        ans = ans + y;
      } else {
        ans = ans + z;
      }
    }
  }
  cout << ans << endl;
}
