You need to explain your meaning better. What are H and M? Are they like H (heads) and T (tails) for coin flipping? It seems you are using "|" to partition the sequence of H and M such that two adjacent events are in the same partition if and only if they have the same outcome, and partitions must be contiguous. But you could certainly present this more clearly, and more legibly.

What probability/probabilities are you trying to quantify??