Rounded tower has 16 doors, behind each there is a chest with gold of captain Flint. These doors are at equal distances to the neighboring ones, and are numbered clockwise from 1 to 16. 16 pirates come to the tower, each having a key, all keys are numbered from 1 to 16. It is known that key with number opens doors with number if and only if . Pirates stand one next to each door, but they do not know the number of the door they stand in front of. Jim Hawkins knows which pirate has which key and wants them to take as small an amount of chests with gold as possible. Jim can turn the tower so that doors are situated in front of pirates as he wants – but still all the numbers go clockwise 1-16 starting from some door. What is the maximum amount of chests with gold pirates can definitely take in such conditions?
(Bogdan Rublyov)