#include <bits/stdc++.h>
using namespace std;
int main() {
  long long cnt = 0, i = 0, cnt1 = 0, cnt2 = 0, n, n1, n2;
  string lock1, togo;
  cin >> n >> lock1 >> togo;
  while (i < n) {
    n1 = lock1[i] - '0';
    n2 = togo[i] - '0';
    if (n1 > n2) {
      cnt1 = n1 - n2;
      cnt2 = 10 - n1 + n2;
      if (cnt1 > cnt2) {
        cnt += cnt2;
      }
      if (cnt1 < cnt2) {
        cnt += cnt1;
      }
      if (cnt1 == cnt2) {
        cnt += cnt1;
      }
    }
    if (n2 > n1) {
      cnt1 = n2 - n1;
      cnt2 = 10 - n2 + n1;
      if (cnt1 > cnt2) {
        cnt += cnt2;
      }
      if (cnt1 < cnt2) {
        cnt += cnt1;
      }
      if (cnt1 == cnt2) {
        cnt += cnt1;
      }
    }
    i++;
  }
  cout << cnt;
  return 0;
}
