Define the distance between two strings of the same length as the numbers of the positions where the characters differ in these two strings.
If two strings of the same length has a distance of no more than $k$, we call these two string satisfy $k-matching$.
Given a string $S$ of length $n$ and a integer $k$. For each $i \in [1, n - 1]$, split $S$ into substrings $A$ and $B$, while $A = S[1,i]$ and $B = S[i + 1, n]$. For all the string pairs formed by some non empty substring of $A$ and some non empty substrings of $B$, count the numbers of pairs satisfying $k-matching$.