Answer
$17.5$ miles
Work Step by Step
The distance travelled is speed multiplied by the time taken.
Let's note the upstream speed of the boat by $x$ miles/hour. Hence, for $3.5$ hours, the distance travelled upstream will be $$\text{Distance upstream} = 3.5x. \tag 1 $$ When the boat travels downstream, the speed is increased by $2$ miles/hour, which will be $x+2$. The time needed downstream was $2.5$ hours. Hence, the distance travelled downstream is
$$\begin{align}
\text{Distance downstream}& = 2.5 ( x + 2 )\\
& = 2.5x + 5 \text{ (applying distributive property).}\tag{2}
\end{align}$$ Since $$\text{Distance upstream} = \text{Distance downstream},$$ equating $(1)$ and $(2)$ we have $$3.5x = 2.5x + 5.$$ Subtracting $2.5x$ from both sides we get $$x = 5.$$ Now substituting the value $x=5$ in $(1)$ we find $$\text{Distance upstream} = 3.5\cdot 5 = 17.5\text{ miles}.$$