Let $S$ be a set of real numbers with mean $M$. If the means of the sets $S\cup \{15\}$ and $S\cup \{15,1\}$ are $M + 2$ and $M + 1$, respectively, then how many elements does $S$ have?
1. Let \( S \) be a set of \( k \) elements with mean \( M \). Therefore, the sum of the elements in \( S \) is \( Mk \).

2. When we add the number 15 to the set \( S \), the new set \( S \cup \{15\} \) has \( k+1 \) elements. The mean of this new set is given as \( M + 2 \). Therefore, the sum of the elements in \( S \cup \{15\} \) is:
   \[
   Mk + 15 = (M + 2)(k + 1)
   \]

3. When we add the numbers 15 and 1 to the set \( S \), the new set \( S \cup \{15, 1\} \) has \( k+2 \) elements. The mean of this new set is given as \( M + 1 \). Therefore, the sum of the elements in \( S \cup \{15, 1\} \) is:
   \[
   Mk + 15 + 1 = (M + 1)(k + 2)
   \]

4. We now have the following system of equations:
   \[
   \begin{cases}
   Mk + 15 = (M + 2)(k + 1) \\
   Mk + 16 = (M + 1)(k + 2)
   \end{cases}
   \]

5. Expanding and simplifying the first equation:
   \[
   Mk + 15 = (M + 2)(k + 1) \\
   Mk + 15 = Mk + M + 2k + 2 \\
   15 = M + 2k + 2 \\
   M = 13 - 2k
   \]

6. Expanding and simplifying the second equation:
   \[
   Mk + 16 = (M + 1)(k + 2) \\
   Mk + 16 = Mk + M + 2M + 2 \\
   16 = M + k + 2 \\
   M = 14 - k
   \]

7. Setting the two expressions for \( M \) equal to each other:
   \[
   13 - 2k = 14 - k \\
   -2k + k = 14 - 13 \\
   -k = 1 \\
   k = -1
   \]

8. Substituting \( k = -1 \) back into the expression for \( M \):
   \[
   M = 14 - (-1) \\
   M = 15
   \]

9. However, this value of \( k \) does not make sense in the context of the problem, as \( k \) must be a positive integer. Therefore, we need to re-evaluate our steps.

10. Re-evaluating the system of equations:
   \[
   Mk + 15 = (M + 2)(k + 1) \\
   Mk + 16 = (M + 1)(k + 2)
   \]

11. Subtracting the second equation from the first:
   \[
   Mk + 15 - (Mk + 16) = (M + 2)(k + 1) - (M + 1)(k + 2) \\
   -1 = (M + 2)(k + 1) - (M + 1)(k + 2) \\
   -1 = Mk + 2k + M + 2 - Mk - k - 2M - 2 \\
   -1 = k - M \\
   M = k + 1
   \]

12. Substituting \( M = k + 1 \) into the first equation:
   \[
   Mk + 15 = (k + 1 + 2)(k + 1) \\
   k(k + 1) + 15 = (k + 3)(k + 1) \\
   k^2 + k + 15 = k^2 + 4k + 3 \\
   15 = 4k + 3 - k \\
   12 = 3k \\
   k = 4
   \]

The final answer is \( \boxed{4} \).