You are considering the sample mean:
$$\bar{X}_{N+M} = \frac{1}{N+M} \sum_{i=1}^{N+M} X_i.$$
The sum-of-squared deviations around this value is:
$$\begin{align}
\sum_{i=1}^N (X_i - \bar{X}_{N+M})^2
&= \sum_{i=1}^N (X_i^2 - 2 \bar{X}_{N+M} X_i + \bar{X}_{N+M}^2) \\[6pt]
&= \sum_{i=1}^N X_i^2 - 2 \bar{X}_{N+M} \sum_{i=1}^N X_i + N \bar{X}_{N+M}^2 \\[6pt]
&= \sum_{i=1}^N X_i^2 - \frac{2}{N+M} \sum_{i=1}^{N+M} \sum_{j=1}^N X_i X_j + \frac{N}{(N+M)^2} \sum_{i=1}^{N+M} \sum_{j=1}^{N+M} X_i X_j. \\[6pt]
\end{align}$$
Assuming your data is IID with mean $\mu$ and variance $\sigma^2$ you have:
$$\begin{align}
\mathbb{E} \bigg( \sum_{i=1}^N X_i^2 \bigg)
&= N (\sigma^2 + \mu^2), \\[6pt]
\mathbb{E} \bigg( \sum_{i=1}^{N+M} \sum_{j=1}^N X_i X_j \bigg)
&= N [\sigma^2 + (N+M) \mu^2], \\[6pt]
\mathbb{E} \bigg( \sum_{i=1}^{N+M} \sum_{j=1}^{N+M} X_i X_j \bigg)
&= (N+M) [\sigma^2 + (N+M) \mu^2]. \\[6pt]
\end{align}$$
We therefore have:
$$\begin{align}
\mathbb{E} \bigg( \sum_{i=1}^N (X_i - \bar{X}_{N+M})^2 \bigg)
&= \mathbb{E} \bigg( \sum_{i=1}^N X_i^2 - \frac{2}{N+M} \sum_{i=1}^{N+M} \sum_{j=1}^N X_i X_j \\[6pt]
&\quad \quad \quad \quad \quad + \frac{N}{(N+M)^2} \sum_{i=1}^{N+M} \sum_{j=1}^{N+M} X_i X_j \bigg) \\[6pt]
&= N (\sigma^2 + \mu^2) - \frac{2N}{N+M} [\sigma^2 + (N+M) \mu^2] \\[6pt]
&\quad \quad \quad \quad \quad \quad \ \ + \frac{N}{N+M} [\sigma^2 + (N+M) \mu^2] \\[6pt]
&= N (\sigma^2 + \mu^2) - \frac{N}{N+M} [\sigma^2 + (N+M) \mu^2] \\[6pt]
&= N \sigma^2 + N \mu^2 - \frac{N \sigma^2}{N+M} - N \mu^2 \\[6pt]
&= \bigg( N - \frac{N}{N+M} \bigg) \sigma^2 \\[6pt]
&= N \bigg( 1 - \frac{1}{N+M} \bigg) \sigma^2 \\[6pt]
&= \frac{N (N+M-1)}{N+M} \cdot \sigma^2. \\[6pt]
\end{align}$$
Consequently, we obtain the following unbiased estimator for $\sigma^2$:
$$S_*^2 \equiv \frac{N+M}{N (N+M-1)} \sum_{i=1}^N (X_i - \bar{X}_{N+M})^2.$$
In the special case where $M=0$ this reduces to the usual sample variance estimator.