﻿import std.stdio, std.range, std.conv, std.algorithm, std.array, std.string, std.ascii, std.math;

void main() {

	readln;
	auto a = readln.strip, b = readln.strip;

	uint sum;
	foreach (i, e; a) {
		auto tmpA = e.to!int, tmpB = b[i].to!int;
		auto minA = min(tmpA, tmpB), maxB = max(tmpA, tmpB);
		auto cl = maxB - minA, tl = 10 - maxB + minA;
		if (cl < tl) {
			sum += cl;
		}
		else {
			sum += tl;
		}
	}

	writeln(sum);
}