Shaq sees the numbers $1$ through $2017$ written on a chalkboard. He repeatedly chooses three numbers, erases them, and writes one plus their median. (For instance, if he erased $-2, -1, 0$ he would replace them with $0$.) If $M$ is the maximum possible final value remaining on the board, and if m is the minimum, compute $M - m$.
1. **Claim that \( M = 2017 \):**
   - Notice that if there was a number greater than \( 2017 \) written on the chalkboard, it would mean that there would have to be another number greater than \( 2017 \) on the chalkboard in order to make that number. 
   - Since all the numbers start off as \( \leq 2017 \), it is impossible to create a number greater than \( 2017 \).

2. **Constructing the maximum value \( M \):**
   - A way to end with \( 2017 \) would be to replace \( 1, 2, 2017 \) with \( 3 \).
   - Then replace \( 3, 3, 2017 \) with \( 4 \).
   - Continue this process: replace \( 4, 4, 2017 \) with \( 5 \), and so on.
   - Eventually, replace \( 2016, 2016, 2017 \) with \( 2017 \).
   - This shows that it is possible to end with \( 2017 \) as the final number.

3. **Claim that \( m = 3 \):**
   - To find the minimum possible final value, consider the smallest possible values that can be generated.
   - The smallest three numbers initially are \( 1, 2, 3 \).
   - Replacing \( 1, 2, 3 \) with \( 3 \) (since the median is \( 2 \) and \( 2 + 1 = 3 \)).
   - Now, the smallest three numbers are \( 3, 4, 5 \), and replacing them will yield a number greater than or equal to \( 3 \).
   - Therefore, the minimum possible final value is \( 3 \).

4. **Compute \( M - m \):**
   - Given \( M = 2017 \) and \( m = 3 \), we have:
   \[
   M - m = 2017 - 3 = 2014
   \]

Conclusion:
\[
M - m = \boxed{2014}
\]