Each switch can connect $4$ machines and it takes one uplink port. So, effectively each switch except the one connecting to the main uplink connects $3$ machines and the one which connects to the main uplink connect to $4$ machines. Thus for $24$ machines we will need $= 1+\left \lceil \dfrac{24-4}{3} \right \rceil = 8$ switches.