Fill up the 3 gallon container and pour the 3 gallons into the 5 gallon container. Then, fill the 3 gallon container back up, and pour it into the 5 gallon container. The 3 gallon container will have 1 gallon left. Empty the 5 gallon container. Pour the remining 1 gallon into the 5 gallon container. Then fill the 3 gallon container back up and pour it into the 5 gallon container. Thus, you have 4 gallons.