You're playing the new retro game called ClearTheBit.
Each level of this game presents you with two integers $a$ and $b$, and $n$ shapes called "bits" that are either squares, circles, or triangles. Each bit has a value assigned to it, and you clear the level using this mechanism:
Your score will be equal to the points gathered using the mechanism above.
Given $a$, $b$, and the description of the $n$ bits in a level, find the maximum score you can achieve.
The first line of input will contain three integers $n$, $a$, and $b$ $(1 \le n, a, b \le 10^6)$.
Each of the following $n$ lines will contain a character $k_i$ and a value $v_i$ $(k_i \in \{s, c, t\}, 1 \le v_i \le 10^5)$, where $k_i$ is the shape of the $i^{th}$ bit and $v_i$ is the value assigned to it.
Print a single integer, the maximum score that can be achieved.
Input | Output |
---|---|
4 1 1 s 3 c 1 t 5 c 2 Copy
|
5 Copy
|
3 1 1 s 3 c 1 t 5 Copy
|
8 Copy
|