Suppose that you take a light necklace, break it at some point, and hold one end in each hand. Take the bead at the end of the left half together with all adjacent beads of the same color, then do the same thing with the right half. A don't-care bead can be treated as either white or black. (All the beads taken from the left half will be the same color, and so will all the beads taken from the right half. However, the color of the 'left' beads may or may not be the same as the color of the 'right' beads.) The problem is to find a point to break the necklace that maximizes the total number of beads thus obtained.
The input consists of one or more lines, each of which contains one necklace description beginning in the first column. A necklace description is just a non-empty string of x's, o's and *'s whose length does not exceed 75. Since necklaces are circular, the last bead is adjacent to the first one. The beads in a necklace are numbered consecutively beginning with 1.
For each necklace, output a line of the form 'N after I', where N is the maximum number of beads obtainable and I is the smallest number such that breaking the necklace after bead I achieves the maximum.
Input must be read from the file "prob15.in",
and output must be written to the file "prob15.out".
All output to the screen will be ignored.
<BOF> xoxoooxxxoooooxooxxoxxxxoooox xx*xooo*xoxoo*oox <EOF>
8 after 9 10 after 16
Dr. Eric Shade