#include <bits/stdc++.h>
using namespace std;
const int maxn = 1100;
int n;
char a[maxn], b[maxn];
int ans;
int main() {
  scanf("%d", &n);
  scanf("%s%s", a, b);
  for (int i = 0; i < n; ++i) {
    int aa = a[i] - '0';
    int bb = b[i] - '0';
    int ni, shun;
    if (bb <= aa)
      ni = aa - bb;
    else
      ni = (aa + 9 - bb + 1);
    if (bb > aa)
      shun = bb - aa;
    else
      shun = (9 - aa + 1) + bb;
    int num = min(shun, ni);
    ans += num;
  }
  printf("%d\n", ans);
  return 0;
}
