Bessie the cow has laid out a row of $N$ rocks, each painted with a single lowercase letter, to build into a fashionable necklace. Reading the rocks in order gives a string of length $N$.
Being protective of her belongings, Bessie does not want to share her necklace with the other cow living on her side of the barn. That cow's name is a string of $M$ characters, and Bessie wants to be sure this length-$M$ string never appears as a contiguous substring of her necklace (otherwise the other cow might mistakenly think the necklace is hers). Bessie decides to remove some rocks so that the other cow's name does not appear as a substring. (When rocks are removed, the remaining rocks keep their original order and join into the new necklace string.)
Determine the minimum number of rocks Bessie must remove.
a and z.a to z.a to z.