ReMorse
题号:NC224878
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

Morse code is an assignment of sequences of dot and dash symbols to alphabet characters. You are to reassign the sequences of Morse code so that it yields the shortest total length to a given message, and return that total length.

A dot symbol has length 1. A dash symbol has length 3. The gap between symbols within a character encoding has length 1. The gap between character encodings has length 3. Spaces, punctuation, and alphabetic case are ignored, so the text

The quick brown dog jumps over the lazy fox.

is encoded as though it were

THEQUICKBROWNDOGJUMPSOVERTHELAZYFOX

For instance, for the input ICPC, the answer is 17. Encode the Cs with a single dot, the I with a dash, and the P with two dots, for an encoding of

− ∙ ∙∙ ∙

which has length (3) + 3 + (1) + 3 + (1 + 1 + 1) + 3 + (1) = 17.

输入描述:

The single line of input consists of a string s (1 ≤ |s| ≤ 32000) of upper-case or lower-case letters, spaces, commas, periods, exclamation points, and/or question marks. Everything but the letters should be ignored. The line will contain at least one letter.

输出描述:

Output a single integer, which is the length of 𝒔 when encoded with an optimal reassignment of the sequences of Morse code.
示例1

输入

复制
ICPC

输出

复制
17
示例2

输入

复制
A

输出

复制
1
示例3

输入

复制
The quick brown dog jumps over the lazy fox.

输出

复制
335