#include <bits/stdc++.h>
int main() {
  int number;
  std::cin >> number;
  char s_source[number], s_target[number];
  std::cin >> s_source;
  std::cin >> s_target;
  int *source = new int[number];
  int *target = new int[number];
  for (int i = 0; i < number; i++) {
    source[i] = s_source[i] - '0';
  }
  for (int i = 0; i < number; i++) {
    target[i] = s_target[i] - '0';
  }
  int count = 0;
  for (int i = 0; i < number; i++) {
    int razn = source[i] - target[i];
    int razn_tens = 0;
    if (razn > 0) {
      razn_tens = target[i] + 10 - source[i];
    } else {
      razn_tens = source[i] + 10 - target[i];
    }
    if (std::abs(razn) >= 0 && std::abs(razn) < razn_tens) {
      count += std::abs(razn);
    } else {
      count += razn_tens;
    }
  }
  std::cout << count << std::endl;
  delete[] source;
  delete[] target;
  return 0;
}
