If I have a known volume of saline/saltwater and a known specific gravity, what is the formula I use to calculate how much salt water to replace to adjust the specific gravity?

Example:

I have a fish tank with 50 gallons of water with a specific gravity of 1.027 and I want to reduce the SG to 1.023 without changing the volume of water. How much water do I remove from the tank and replace with distilled water?

Yes, I know the real world answer is "some" and then retest... I just got curious last night as I was cleaning my fish tanks.