If you just need an _upperbound_ , that is much easier.
Let $X =$ the number of times the sequence appears. There are $M-K+1$ possible starting possitions, so by linearity of expectation, $E[X] = (M - K + 1) n^{-K} < M n^{-K}.$
Now $E[X] = \sum_{k \ge 0} k P(X = k) = \sum_{k \ge 1} k P(X = k) \ge \sum_{k \ge 1} P(X=k) = P(X \ge 1) =$ prob that the $K$-sequence appears at least once. So this prob is upperbounded by $E[X] < M n^{-K}$.
I am saying exactly the same thing as all the various comments, except that the above also formally proves it is an upperbound.