#include <bits/stdc++.h>
int poww(int a, int b) {
  int ans = 1, base = a;
  while (b != 0) {
    if (b & 1 != 0) ans *= base;
    base *= base;
    b >>= 1;
  }
  return ans;
}
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n;
  string a, b;
  cin >> n;
  cin >> a >> b;
  int s = 0, l = a.size();
  for (int i = 0; i < l; i++) {
    if (a[i] > b[i]) {
      int x = a[i] - b[i], y = b[i] + 10 - a[i];
      if (x > y)
        s += y;
      else
        s += x;
    } else if (a[i] < b[i]) {
      int x = b[i] - a[i], y = a[i] + 10 - b[i];
      if (x > y)
        s += y;
      else
        s += x;
    }
  }
  cout << s << endl;
}
