A group on a sponsored hike covered one eighth of the total distance on the first day.

The next day they covered one quarter of what was left.

The following day they covered two fifths of the remainder and on the fourth day half of the remaining distance.

The group now have 12 miles left.

How many miles have they walked?