#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, tot = 0, i, temp1, temp2, temp3, fin;
  char inp1[1005], inp2[1005];
  scanf("%d%s%s", &N, inp1, inp2);
  for (i = 0; i < N; i++) {
    temp1 = abs(inp1[i] - inp2[i]);
    temp2 = abs('9' - inp1[i]) + (inp2[i] - '0') + 1;
    temp3 = abs(inp1[i] - '0') + ('9' - inp2[i]) + 1;
    fin = min(min(temp1, temp2), temp3);
    tot += fin;
  }
  printf("%d\n", tot);
  return 0;
}
