This formalization reduces to the counting of number of symbol occurrences and the computation of edit distances.
: where |A| a stands for the number of occurrences of character a in string A and δ(A, B) stands for the edit distance between strings A and B with only insertion and deletion as edit operations.