Three sailors were shipwrecked on an island. To make sure that they would

have enough to eat, they spent the day gathering bananas. They put the

bananas in a large pile and decided to divide the bananas equally among

themselves the next morning. However, each sailor distrusted the other

two, so after they were asleep, one of the sailors awoke and divided the

pile of bananas into three equal shares. When he did so, he found that he

had one banana left over; he fed it to a monkey. He then hid his share and

went back to sleep. A second sailor awoke and divided the remaining bananas

into three equal shares. He too found that he had one banana left over and

fed it to the monkey. He then hid his share and went back to sleep. The

third sailor awoke and divided the remaining bananas into three equal shares.

Again, one banana was left over, so he fed it to the monkey. He then hid his

share and went back to sleep. When the sailors got up the next morning, the

pile was noticeably smaller, but since they all felt guilty, none of them

said anything and they all agreed to divide the bananas. When they did so,

one banana was left over and they again gave it to the monkey.

What was the minimal possible number of bananas at the beginning?