We have a long, straight strip of paper. We repeatedly perform folding steps. In one folding step we choose a single crease line perpendicular to the long edge and fold the entire current stack along it, so that every layer lying over that line is folded together; it is never allowed to fold only some of the layers.
After performing several folding steps, unfold the strip completely and look along its long edge. The creases turn out to be equally spaced, cutting the strip into congruent stripes. Reading the strip from one end to the other, each crease turns one of two ways, written as the character A or V.
We are also told that in the fully folded state the strip is exactly one stripe long, that is, all stripes end up stacked on top of one another (thickness is ignored).
Given the resulting sequence of creases in the fully unfolded strip, determine the minimum number of folding steps needed to obtain it from a flat strip.
A single folding step may create more than one crease at once, because parts of the strip already lie on top of each other from earlier steps; still, all overlapping layers are folded together. If the sequence has $n$ creases, folding once at each crease in order always works and uses $n$ steps, but that is usually not the minimum.
The input contains several test cases, each on its own line. Each line is a nonempty string of the characters A and V describing the creases along the long edge of the strip. Every string has length less than $200$. The input ends at end of file.
For each test case, print on its own line the minimum number of folding steps required to produce the described strip.