Suppose the vessel initially contains 8 litres of liquid Let x litres of this liquid be replaced with water
Quantity of water in new mixture = (3−3x8+x) litres
Quantity of syrup in new mixture (3−5x8) litres
∴(3−3x8+x)=(5−5x8)⇒5x+24=40−5x
⇒10x=16⇒x=85
So part of the mixture replaced = (85×18)=15