A ship traveled for a total of 147 miles over the course of 8 hours. Heading south, the ship traveled at an average speed of 15 miles per hour, and heading east, it traveled at an average speed of 24 miles per hour. For how many hours was the ship heading south?