Let's say the mass density is $\rho$.
Then the mass of the stem $m_s$ will be $\rho V_s$, where $V_s$ is the volume of the stem. Likewise for the cap, $m_c = \rho V_c.$
So, $m_s = \rho \pi r_s^2 h = 2 \pi \rho$ and $m_c = (2/3) \rho \pi r^3 = (2/3) \rho \pi a^3.$
If we take the plane joining them to be $z=0$, positive up, then the center of mass of the stem is $d_s \cdot m_s = 2 \pi \cdot -1 = -2 \pi \rho$, where $d_s$ is the displacement of the center of mass from the plane.
This means that $d_c \cdot m_c = + 2 \pi \rho$. The center of mass of a hemispherical solid of radius $a$ lies 3/8ths of the way up from the base. Hence,
$$\frac{3a}{8} \cdot \frac{2 \pi a^3 \rho }{3} = 2 \pi \rho \to a = \sqrt[4]{8} \approx 1.682.$$