Answer: $\mathbf{n - p}$.
There are $p$ components and $n$ vertices. A component can have any no. of vertices but it must be a tree.
Let the no. of vertices in $1$st component be $x_1$, in $2$nd component $x_2$, in $3$rd component $x_3$, and so on. For the $p$th component, there will be $x_p$ vertices.
- In a tree with $n$ vertices, there are exactly $n - 1$ edges.
So, In $1$st component $\qquad \Rightarrow$ $(x_1 - 1)$ edges.
$2$nd component $\qquad \Rightarrow$ $(x_2 - 1)$ edges.
$\vdots$
In $p$th component $\qquad \Rightarrow$ $(x_p - 1)$ edges.
Therefore, total no. of edges $=[(x_1 + x_2 + x_3 +\ldots+ x_p) - p]$
$(x_1 + x_2 + x_3 + \ldots+ x_p) = n$ (total no. of vertices).
So, total no. of edges is $(n - p)$.