WOW, there is actually 2 ways then.
The other would be to…
Take the 5 gallon bucket (full) and dump it into the 3 leaving 2 gallons in the 5 gallon bucket.
Then empty the 3 gallon bucket.
Pour the 2 gallons from the 5 gallon bucket into the 3 gallon bucket, leaving exactly 2 gallons in the 3 gallon bucket.
Then fill the 5 gallon bucket and use it to top of the 3 gallon bucket.
You will have poured out exactly 1 gallon out of the 5 gallon bucket, leaving exactly 4 gallons in the 5 gallon bucket.