eolymp
bolt
Try our new interface for solving problems
Problems

Boustrophedon

Boustrophedon

\includegraphics{https://static.e-olymp.com/content/1d/1d61449a102c28e093a56453b5077792d275f0ac.jpg} Boustrophedon is a type of bi-directional text, mostly seen in ancient manuscripts and other inscriptions. Every other line of writing is reversed. Rather than going left-to-right as in modern English, alternate lines in boustrophedon must be read in opposite directions. The individual character images on reversed lines are mirrored too. Notice that some Latin letters are symmetrical, and so do not need mirroring on the reversed lines. This way, some English texts may be written as boustrophedons with the standard font. The symmetrical letters are: \textbf{A, H, I, M, O, T, U, V, W, X, Y.} The boustrophedon must consist of at least \textbf{3} lines. All lines of the boustrophedon must have the same number of characters (let us call it the \textit{width} of the boustrophedon), except the last line, which may be shorter. The text contains only capital English letters (no spacing or punctuation). You program must find the width of the widest boustrophedon that can be constructed from the given text and does not need letter mirroring. \InputFile Input file contains a single string composed of capital Latin letters. String length is between \textbf{1} and \textbf{100000 }characters. \OutputFile Output file must contain a single integer --- maximum boustrophedon width. If there is no solution, output zero.
Time limit 1 second
Memory limit 256 MiB
Input example #1
A
Output example #1
0