#include <bits/stdc++.h>
using namespace std;
const int limit = 205;
int up(int i, int j) {
  int ans = 0;
  while (i != j) {
    i++;
    if (i == 10) i = 0;
    ans++;
  }
  return ans;
}
int down(int i, int j) {
  int ans = 0;
  while (i != j) {
    i--;
    if (i == -1) i = 9;
    ans++;
  }
  return ans;
}
int main() {
  int n;
  string a, b;
  int ans = 0;
  cin >> n;
  cin >> a >> b;
  for (int i = 0; i < n; i++) {
    ans += min(up(a[i] - '0', b[i] - '0'), down(a[i] - '0', b[i] - '0'));
  }
  printf("%d\n", ans);
}
