The answer is 27 pineapples.

To determine the answer you need to determine how many pineapples were available to each man.

The fourth man took his rightful share (1/4 of the total pineapples left when he woke up). There were 6 pineapples left after he took his share. Therefore 6 is 3/4 of the total pineapples that were available to him. Let x represent the total number of pineapples.

(3/4) x =6 So x = 8

The third man took 1/3 of the total pineapples. We know now that there were 8 pineapples left after he took his share. Therefore 8 is 2/3 of the total pineapples that were available to him. Let x represent the total number of pineapples.

(2/3) x =8 So x = 12

The second man took 1/3 of the total pineapples. We know now that there were 12 pineapples left after he took his share. Therefore 12 is 2/3 of the total pineapples that were available to him. Let x represent the total number of pineapples.

(2/3) x =12 So x = 18

The first man took 1/3 of the total pineapples. We know now that there were 18 pineapples left after he took his share. Therefore 18 is 2/3 of the total pineapples that were available to him. Let x represent the total number of pineapples.

(2/3) x =18 So x = 27