ENG  RUSTimus Online Judge
Online Judge
Online contests
About Online Judge
Frequently asked questions
Site news
Problem set
Submit solution
Judge status
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests

1929. Teddybears are not for Everyone

Time limit: 1.0 second
Memory limit: 64 MB
The world is in danger! Teddy bears rose against their masters. They are trying to seize the power and turn people into their toys. The only chance now is resistance groups, which are forming all over the world. We got bitter experience in hard battles with teddy bears and know, that in order to fight effectively, resistance group should contain three fighters: a scout (who can detect the enemy in time), a signalman (to provide connection with the center of resistance) and teddyhater, a person, who can withstand the charms of a bear and doesn't melt at the sight of him to strike a fatal blow. Moreover, everyone can learn how to be a scout or a signalman, but taddyhater's skill is given from birth.
A boy Holden came to the resistance headquarters today. He decided it is time for him to join the resistance group and to save the world. Holden, however, is very choosy boy, he wants to examine each appropriate group and choose the one, he wants to fight in. General headquarters insist that after Holden will make his choice, they should be able to form the three-man groups from the rest of fighters so that every group will contain at least one teddyhater. It takes Holden one minute to consider whether the group is good for him, but if group doesn't meet the requirement of General headquarter, Holden will not waste his time considering this variant.
World is close to death and needs fighters. No time is left. You have to count how much time it takes Holden to think.


The first line contains two integers n — the number of fighters, including Holden, and m — the number of teddyhaters (6 ≤ n ≤ 999; 1 ≤ mn; n is divisible by 3). The second line contains m integers divided by space — teddyhater's numbers. Holden has number 1.


Output the time in minutes that Holden needs for thinking.


6 4
2 3 4 6
Problem Author: Olga Soboleva (prepared by Kirill Devyatkin)
Problem Source: Ural Regional School Programming Contest 2012