#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ans = 0;
  cin >> n;
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < n; i++) {
    int a = s[i] - '0', b = t[i] - '0';
    ans += min(abs(a - b), 10 - abs(a - b));
  }
  cout << ans;
}
