This is a numerical-answer question. The correct answer is shown below.
[Solution by Dr. Abubacker] Magnesium nitrate crystallises as the hexahydrate, $Mg(NO_3)_2\cdot6H_2O$ ($X=6$). Barium nitrate crystallises without water, $Ba(NO_3)_2$ ($Y=0$). Sum $=6$. Answer: 6.