maximum of $p$ sons means a node can have maximum $p$ children and therefore $p$ pointer fields are allocated in each node. Now total number of nodes is $q$, so total number of fields allocated is $pq$. Every node in the tree must be pointed by its parent (except root), so $q - 1$ fields must point to some node. So fields which are NULL = $pq - (q - 1) = q(p-1)+1$