#include <bits/stdc++.h>
using namespace std;
char str[10000], src[10000];
int n;
int main() {
  scanf("%d", &n);
  scanf("%s %s", str, src);
  int cnt = 0;
  for (int(i) = 0; (i) < n; (i)++) {
    int res = 0;
    int st = min(str[i], src[i]);
    int ed = max(str[i], src[i]);
    int cou = ed - st;
    cnt += min(cou, 10 - cou);
  }
  cout << cnt << endl;
  return 0;
}
