For k∈N0 we denote by bk the number of words from the alphabet {b,@,l,t,i,c,w,a,y} of maximum length k, so that b2023=∣B∣. Furthermore, we denote by mk the number of words of maximum length k+2 from the alphabet {m,a,t,h}, that contain the letter t exactly twice, so that m2023=∣M∣.
For example, we have b0=1 (coming from the empty word), b1=b0+9=10 (adding 9 one-letter words) and b2=b1+92=91 (adding 92 two-letter words). More generally, we have
bk=bk−1+9k(∗)
for all k≥1, since we can form exactly 9k words of length k from the given alphabet. The recursion
bk=1+9bk−1(∗∗)
is also true for all k≥1, since every word of maximum length k from the given alphabet is either the empty word (1 case) or the concatenation of a word of maximum length k−1 and one of the nine letters from the given alphabet (9bk−1 cases).
On the other hand, we have m0=1 (coming from the word tt), m1=m0+9=10 (adding 9 words of the form tx, txt and xtt with x∈{h,a,m}) and m2=m1+54=64 (adding 6⋅9=54 words of the form ttxy, txty, txyt, xtty, xtyt and xytt with x,y∈{h,a,m}).
Lemma. The recursion
mk+2=9mk+1−27mk+27mk−1+1
is true for k≥1.
*Proof of the lemma.* We will consider two further sequences, first the sequence (pk)k∈N0, where pk is the number of words of maximum length k+2 from the alphabet {m,a,t,h}, that contain the letter t exactly once. We will also consider the sequence (qk)k∈N0, where qk is the number of words of maximum length k+2 from the alphabet {m,a,t,h}, that do not use the letter t at all (i.e. words of maximum length k+2 from the alphabet {h,a,m}).
Let k≥1 for the moment. A word of maximum length k+2 from the alphabet {m,a,t,h}, that contains the letter t exactly twice, is either
* the concatenation of the letter t with a word of maximum length k+1 with exactly one occurrence of the letter t (of which there are pk−1 cases) or
* the concatenation of a letter x∈{h,a,m} with a word of maximum length k+1 with exactly two occurrences of the letter t (of which there are 3⋅mk−1 cases).
We conclude that
mk=pk−1+3mk−1.(∗∗∗)
In a similar spirit, we obtain
pk=qk−1+3pk−1(∗∗∗∗)
and
qk=1+3qk−1.(†)
Equation (***) tells us that pk−1=mk−3mk−1, from which we obtain pk=mk+1−3mk by shifting indices. We plug both expressions into equation (****) and obtain
mk+1−3mk⇔qk−1=qk−1+3(mk−3mk−1)=mk+1−6mk+9mk−1.(††)
Plugging equation (††) and its index shift into equation (†) yields the recursion from the lemma. □
Thanks to the lemma. By induction hypothesis, there exist natural numbers r,s,t∈N such that mk−1=bk−1+3k−1r, mk−2=bk−2+3k−2s and mk−3=bk−3+3k−3t. It follows that
mk≡9bk−1−27bk−2+27bk−3+1(mod3k),
from which we conclude
mk−bk≡−bk+9bk−1−27bk−2+27bk−3+1≡−bk+9bk−1−27(bk−1−9k−1)+27(bk−1−9k−1−9k−2)+1≡−bk+9bk−1+1(mod3k).
thanks to equation (*). By equation (**) we have mk−bk≡0(mod3k), which finishes the induction step.
We now show that bk≡mk(mod3k) for all k∈N≥0, which yields the desired statement when we put k=2023.
We are going to show our claim by strong mathematical induction on k. The claim is true for k=0, because the difference b0−m0=0−0=0 is divisible by 30=1. It is true for k=1, because the difference b1−m1=10−10=0 is divisible by 31=3. It is true for k=2, because the difference b2−m2=91−64=27 is divisible by 32=9.