Problem

19 /19


Message decoding

Problem

A sequence of words in the Latin alphabet {A, E, P} is transmitted over the communication channel. The length of each word does not exceed 10 letters, the words may not be meaningful words of the Russian language. Each word is passed as an integer, obtained as follows:
1)      First, the word is encoded using a non-uniform binary code with code words: E – 0; P – 10; And – 11;
2)      The number 1 is assigned to the received binary sequence on the right;
3)      The resulting binary string is reversed, that is, from the string 01010111 we get 11101010;
4)      The desired number N is calculated as a result of converting the binary chain obtained in the previous step to the decimal system.
 

For example, the character sequence AAEEP would be converted to 11110010, then (adding one to the end) to 111100101, and then to a number: 1 + 2 + 4 + 8 + 64 + 256 = 335. Note that 335 = 1010011112.
Write a program that, having received a natural number as input, decodes the transmitted message and determines how many times vowels occur in the original word. It is assumed that the input number can be represented as an integer type value in the programming language used.

Sample input
5483

Sample output
AERAERR
4

Note. In this example: source word: AEPAEPP. Code binary sequence: 110101101010, after adding 1 on the right we get: 1101011010101.