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