ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

2138. The Good, the Bad and the Ugly

Time limit: 0.5 second
Memory limit: 256 MB
Everyone knows that computer see integers not in the same way as humans do. Instead of digits from 0 to 9 they use digits from 0 to 255. For example, the integer 1 000 000 can by represented by a computer with three digits 15, 66, 64 (let’s denote it as 15;66;64), because 15· 2562 + 66· 256 + 64 = 1 000 000. On top of that, integers in computers have a fixed size. In this problem the size of an integer is always 4 digits, so the integer 1 000 000 will be represented as 0;15;66;64. Computers use this exact format to communicate with each other.
This system may seem strange, but it works. Or, it used to work, until an evil genius reversed the order of digits in half of the computers! These computers now interpret 0;15;66;64 not as 1 000 000 but as 1 078 071 040 (64· 2563 + 66· 2562 + 15· 256 + 0 = 1 078 071 040). No one knows how to fix it, so the computers that are left untouched are now called “good”, and other computers are called “bad”. In order for “good” and “bad” computers to communicate, the integers that are read incorrectly must be translated into correct integers.
For example, let A and B be two computers of opposite types. Let’s say the computer A wants to send the computer B a non-negative integer not exceeding 4 294 967 295. The computer A writes this integer down with four digits from 0 to 255 and sends them to the computer B. Computer B reads the received digits as v, which doesn’t necessary match the integer the computer A was trying to send.
Write a program that would help a “good” or a “bad” computer B determine, what integer the computer A of the opposite type tried to send.

Input

The first line contains one word, denoting the type of the computer A, which sent the integer: “GOOD” (without quotes), if the computer is “good”, and “BAD” (without quotes), if the computer is “bad”.
The second line contains a non-negative integer v that the computer B received (0 ≤ v ≤ 4 294 967 295).

Output

In the only line output the non-negative integer that the computer A sent.

Samples

inputoutput
GOOD
16777216
1
BAD
1000
3892510720

Notes

In the first example the integer 16 777 216 = 1·2563 + 0·2562 + 0·256 + 0 was read by the “bad” computer B from digits 0;0;0;1. The “good” computer A wrote the integer 0·2563 + 0·2562 + 0·256 + 1 = 1.
In the second example the integer 1000 = 0·2563 + 0·2562 + 3·256 + 232 was read by the “good” computer A from digits 0;0;3;232. The “bad” computer B wrote the integer 232·2563 + 3·2562 + 0·256 + 0 = 3 892 510 720.
Problem Author: Aidar Islamov
Problem Source: Ural School Programming Contest 2019