Entropy

No attempts yetTime limit1sMemory limit128 MB

Problem

In 1948, Claude E. Shannon, in The Mathematical Theory of Communication, introduced his famous formula for the entropy of a discrete set of probabilities p1,,pnp_1, \ldots, p_n:

H=ipilog2pi.H = -\sum_{i} p_i \log_2 p_i.

We apply this formula to a text string by letting pip_i be the relative frequency of occurrence of each distinct character in the string. For example, the string Northeastern European Regional Contest, whose length is 38 (including 3 spaces), has entropy 3.8833.883 when rounded to 3 digits after the decimal point. The table below lists the relative frequency pip_i and the corresponding entropy term pilog2pi-p_i \log_2 p_i for each distinct character of this string.

charoccurspip_ipilog2pi-p_i \log_2 p_icharoccurspip_ipilog2pi-p_i \log_2 p_i
space30.0790.0790.2890.289i10.0260.0260.1380.138
C10.0260.0260.1380.138l10.0260.0260.1380.138
E10.0260.0260.1380.138n40.1050.1050.3420.342
N10.0260.0260.1380.138o40.1050.1050.3420.342
R10.0260.0260.1380.138p10.0260.0260.1380.138
a30.0790.0790.2890.289r30.0790.0790.2890.289
e50.1320.1320.3850.385s20.0530.0530.2240.224
g10.0260.0260.1380.138t40.1050.1050.3420.342
h10.0260.0260.1380.138u10.0260.0260.1380.138

Given a string, compute its entropy.

Input

The input consists of a single line containing a string of at least 1 and at most 1000 characters. Every character is one of 09, az, AZ, . (dot), or a space. Leading, internal, and trailing spaces are all part of the string.

Output

Print a single line containing the entropy H=ipilog2piH = -\sum_{i} p_i \log_2 p_i of the input string, where pip_i is the relative frequency of each distinct character. Round the answer to exactly 3 digits after the decimal point.