Introduction - If you have any usage issues, please Google them yourself
1. Each necklace consists of N randomly arranged red, white and blue beads (3<=N<=350).
2. Participants cut and straighten the necklace somewhere; then collect the same color beads from one end to the other until they meet a different color bead; and then do the same thing from the other end. The color of beads collected at one end can be different from that collected at the other end. )
3. When encountering white beads, they can be viewed as either blue beads or red beads, depending on the needs of collecting beads.
4. Find a place to cut off the necklace and collect as many pearls of the same color as possible. The winner can get a pearl necklace free of charge.
Now please help me to write a program to calculate how many beads can be collected from a necklace. The following examples show two necklaces when N = 29: