Compacting Stickers#4522

Compacting Stickers

1 second
64 megabytes
Very easy

The text on a sticker consists of words formed from uppercase and lowercase Latin letters. Words are separated by spaces, line breaks, and/or the following punctuation marks: ",", ".", "!", "?".

There can be any number of spaces and empty lines before and after the words, but after each word there is at most one punctuation mark. The sticker is printed in a monospace font, so every character occupies on the paper a rectangle of fixed size. The sticker itself is a minimal rectangle enclosing the text plus a margin of one character in width.

Since many copies of the sticker will be printed, it is necessary to minimize the amount of paper used. For this, the sticker should be arranged so that its area is as small as possible. For example, consider a sticker with the following text:

Our pink elephants have great size and a small price. Buy our elephants!

If printed on a single line, the sticker will have an area of \left(72 + 2\right) \times \left(1 + 2\right) = 222 characters. On the other hand, if arranged over four lines as follows:

the sticker will require only \left(18 + 2\right) \times \left(4 + 2\right) = 120 characters.

Your task is, given the text of a sticker, to break it into lines so as to achieve the smallest possible area for the sticker. A line break may be inserted after any word or any punctuation mark (but not before a punctuation mark). One space must separate each word from the preceding word or punctuation mark on the same line. You do not need to preserve other spaces or line breaks from the input file.

Input

The input contains one or more lines of the sticker text. The text contains only the following characters: uppercase letters "A" to "Z", lowercase letters "a" to "z", punctuation marks ",", ".", "!", "?", spaces, and line breaks. The text length does not exceed characters. The text always contains at least one non-space character, and the first such character is always a letter.

Output

Output a single integer — the area of the smallest possible sticker.

Examples

Example 1

Loading
Loading