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