Let $A$ be an $m \times n$ matrix and $B$ be an $n \times p$ matrix. Let
$$S=\left \{Bx\mid x\in \mathbb{R}^p \text{ and } ABx=0\right \}$$
Prove that $\dim(S)=\operatorname{rank}(B)-\operatorname{rank}(AB)$
What I thought is actually the collection of vector spanning by the column vector of $B$, so it seems that $\operatorname{rank}(S)$ is somehow equal to $\operatorname{rank}(B)$ (I don't know how to prove it, or maybe I'm wrong)
Then, I tried to use rank-nullity theorem
$$\dim(S)=\operatorname{rank}(B)+\operatorname{rank}(S)$$
But I already get stuck here