#include <bits/stdc++.h>
using namespace std;
int ans;
int main() {
  int n, up, down, x;
  string s1, s2;
  cin >> n >> s1 >> s2;
  for (int i = 0; i < n; i++) {
    if (s1[i] == s2[i]) continue;
    x = max(char('0' + s1[i]), char('0' + s2[i]));
    up = abs(char('0' + s1[i]) - char('0' + s2[i]));
    if (x == char('0' + s1[i]))
      down = 9 - char('0' + s1[i]) + 1 + char('0' + s2[i]);
    else
      down = 9 - char('0' + s2[i]) + 1 + char('0' + s1[i]);
    ans += min(up, down);
  }
  cout << ans;
}
