Drink 8 bottles of water, leaving 8 empty bottles. Replace six empty bottles with two bottles of water. If you drink any more, there will always be four empty bottles.
Three more bottles were replaced with 1 bottle of water, and only two empty bottles were left after drinking, and then they could not be replaced.
So they drank 24+8+2+ 1=35 bottles.