Gromah and LZR have entered the seventh level. There are a sequence of gemstones on the wall. After some tries, Gromah discovers that one can take exactly three successive gemstones with the same types away from the gemstone sequence each time, after taking away three gemstones, the left two parts of origin sequence will be merged to one sequence in origin order automatically. For example, as for "ATCCCTTG", we can take three 'C's away with two parts "AT", "TTG" left, then the two parts will be merged to "ATTTG", and we can take three 'T's next time. The password of this level is the maximum possible times to take gemstones from origin sequence. Please help them to determine the maximum times.
Gromah and LZR have entered the seventh level. There are a sequence of gemstones on the wall. After some tries, Gromah discovers that one can take exactly three successive gemstones with the same types away from the gemstone sequence each time, after taking away three gemstones, the left two parts of origin sequence will be merged to one sequence in origin order automatically. For example, as for "ATCCCTTG", we can take three 'C's away with two parts "AT", "TTG" left, then the two parts will be merged to "ATTTG", and we can take three 'T's next time. The password of this level is the maximum possible times to take gemstones from origin sequence. Please help them to determine the maximum times.