Greetings from Brasil
Let us call the distance AB of Y (in the problem nothing is said about this dimension, so lets call of Y).
From the attached drawing we can conclude that:
AB + BC = AC
where
AB = Y
BC = 2X + 4
AC = 24
then
AB + BC = AC
Y + (2X + 4) = 24
In my view this question is incomplete