I can't resist to show how this is done using ray transfer matrices. There are two key parameter at any point along a light ray: the distance $x$ of the point from the optical axis, and the angle $\theta$ of the ray with the horizontal. Then any optical component of the system can be represented as a $2\times 2$ matrix which transform the pair $(x,\theta)$ for the incoming ray into the pair $(x',\theta')$ for the outgoing ray:
$$\begin{pmatrix}x'\\\theta'\end{pmatrix}=\begin{pmatrix}\times&\times\\\times&\times\end{pmatrix}\begin{pmatrix}x\\\theta\end{pmatrix}.$$
By using what you know, you can easily write down that
- a thin lens has a matrix
$$L=\begin{pmatrix}1&0\\-\dfrac{1}{f}&1\end{pmatrix}$$
where $f$ is the focal distance;
- a thickness $d$ of empty space has a matrix
$$S=\begin{pmatrix}1 & d\\0&1\end{pmatrix}.$$
Onto your problem: we have a lens of focal $f_1$ (matrix $L_1$), empty space and another lens of focal $f_2$ (matrix $L_2$), so the matrix for the whole system is simply the product of the matrices, in reverse order
$$M=L_2\ S\ L_1
=\begin{pmatrix}1&0\\-\dfrac{1}{f_2}&1\end{pmatrix}
\begin{pmatrix}1 & d\\0&1\end{pmatrix}
\begin{pmatrix}1&0\\-\dfrac{1}{f_1}&1\end{pmatrix}
=\begin{pmatrix}1-\dfrac{d}{f_1}&d\\-\left(\dfrac{1}{f_1}+\dfrac{1}{f_2}-\dfrac{d}{f_1f_2}\right)&1-\dfrac{d}{f_2}\end{pmatrix}$$
and you can read the focal distance in the bottom left corner! As you see, 99% of my exposition is just explaining the method. The actual computation is that trivial, systematic, triple matrix product. No monkeying about with geometry all the time: you just need to do it once to deduce the matrices for common components.