#include <bits/stdc++.h>
using namespace std;
char s1[1005], s2[1005];
int main() {
  int n;
  cin >> n >> s1 + 1 >> s2 + 1;
  int ans = 0;
  for (int i = 1; i <= n; i++)
    ans += min(abs(s1[i] - s2[i]), (10 - abs(s1[i] - s2[i])));
  cout << ans << endl;
  return 0;
}
