Under construction

Still being built. Things may change

Happiness Score

Interview

Time limit1sMemory limit1024 MB

Summary
Given one message, count letters that appear in HAPPY and SAD, then print the happiness index as a percentage rounded to two decimals.
Level

Easy2 of 10

Topics
String, Implementation
Solved
No attempts yet

Problem

Jim is a boy who has been feeling down since the COVID-19 pandemic, and he feels like he carries the weight of the whole world. Jim wants to measure how happy his friends are. One method he thinks of is to analyze the text messages his friends send and judge whether they are happy. If a letter in a message appears in the word HAPPY, that letter is a happy letter. If it appears in the word SAD, it is a sad letter. The letter A appears in both words, so it counts as both happy and sad. The letter B appears in neither word, so it is neither happy nor sad.

The happiness index of a message is calculated from a happy score and a sad score. Each happy letter increases the happy score PHP_H by one, and each sad letter increases the sad score PGP_G by one. The happiness index HH is calculated as follows.

H=PHPH+PGH = \frac{P_H}{P_H + P_G}

Letters that are neither happy nor sad are not counted in either PHP_H or PGP_G. If PH=PG=0P_H = P_G = 0, the happiness index is assumed to be 0.50.5.

For example, suppose a friend sends this message.

SAD MOVIES ALWAYS MAKE ME CRY

The letter A appears 4 times (once in SAD, twice in ALWAYS, once in MAKE) and Y appears 2 times (once in ALWAYS, once in CRY), so the happy score is 6. The letter S appears 3 times (in SAD, MOVIES, and ALWAYS), A appears 4 times, and D appears once in SAD, so the sad score is 8. Since PH=6P_H = 6 and PG=8P_G = 8, the index is H=614=0.4286H = \frac{6}{14} = 0.4286, or 42.86%. Because the index is below 50%, the friend is sad.

Input

The input is given through standard input. It consists of one line containing a text message. The message is made only of English alphabet words in uppercase, and the words are separated by spaces. The maximum length of a word is 20, and the maximum number of words is 80.

Output

Print the happiness index as a percentage, without the % sign. Round it to two decimal places. If PHP_H and PGP_G are both 0, the happiness index is 0.5, so print 50.00. Note this case.

Examples3

  1. Example 1

    Input
    SAD MOVIES ALWAYS MAKE ME CRY
    
    Expected output
    42.86
    
  2. Example 2

    Input
    ICPC PROGRAMMING
    
    Expected output
    75.00
    
  3. Example 3

    Input
    WRITING
    
    Expected output
    50.00