If we sum up all the degrees (i.e degrees of all the vertices) we will get twice the number of edges. That is the degree sum formula consequence of the handshaking lemma. https://en.wikipedia.org/wiki/Handshaking_lemma
We have vertices with degree $k$ = $n_k$
Summing up gives:
$n_1 + 2n_2 + 3n_3 + . . . + kn_k = 2e$
Here $e$ is the total number of edges. Given the graph is a tree, so we have:
$e = N - 1$
where $N$ is the total number of vertices and:
$N = n_1 + n_2 + ...+ n_k$
so,
$\implies n_1 + 2n_2 + 3n_3 + . . . + kn_k = 2(n_1 + n_2 + ...+ n_k - 1)$
rearranging,
$\implies n_1 + 2n_2 + 3n_3 + . . . + kn_k = 2n_1 + 2n_2 + ...+ 2n_k - 2$
$\implies n_1 + (2-2)n_2 + (3-2)n_3 + . . . + (k-2)n_k + 2 = 2n_1$
$\implies n_1 = n_3 + 2n_4 + 3n_5 +. . . + (k-2)n_k + 2$
There we get it, $n_1$ is the number of vertices with degree = 1.