Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

This round has an unusual addition to the rules. For each problem you must use distinct language. Thus, if you have a submission that has passed at least one test or is being tested at the moment, then for this task you can use only this language and can not use it for other tasks. More details can be read by the link. Different implementations of the same language are considered to be the same language (for example, in C++ you can only solve one problem, regardless of the exact chosen compiler).

No tags yet

No tag edit access

H. Endless Roses Most Beautiful

time limit per test

1 secondmemory limit per test

256 megabytesinput

standard inputoutput

standard outputArkady decided to buy roses for his girlfriend.

A flower shop has white, orange and red roses, and the total amount of them is *n*. Arkady thinks that red roses are not good together with white roses, so he won't buy a bouquet containing both red and white roses. Also, Arkady won't buy a bouquet where all roses have the same color.

Arkady wants to buy exactly *k* roses. For each rose in the shop he knows its beauty and color: the beauty of the *i*-th rose is *b*_{i}, and its color is *c*_{i} ('W' for a white rose, 'O' for an orange rose and 'R' for a red rose).

Compute the maximum possible total beauty of a bouquet of *k* roses satisfying the constraints above or determine that it is not possible to make such a bouquet.

Input

The first line contains two integers *n* and *k* (1 ≤ *k* ≤ *n* ≤ 200 000) — the number of roses in the show and the number of roses Arkady wants to buy.

The second line contains a sequence of integers *b*_{1}, *b*_{2}, ..., *b*_{n} (1 ≤ *b*_{i} ≤ 10 000), where *b*_{i} equals the beauty of the *i*-th rose.

The third line contains a string *c* of length *n*, consisting of uppercase English letters 'W', 'O' and 'R', where *c*_{i} denotes the color of the *i*-th rose: 'W' denotes white, 'O' — orange, 'R' — red.

Output

Print the maximum possible total beauty of a bouquet of *k* roses that satisfies the constraints above. If it is not possible to make a single such bouquet, print -1.

Examples

Input

5 3

4 3 4 1 6

RROWW

Output

11

Input

5 2

10 20 14 20 11

RRRRR

Output

-1

Input

11 5

5 6 3 2 3 4 7 5 4 5 6

RWOORWORROW

Output

28

Note

In the first example Arkady wants to buy 3 roses. He can, for example, buy both red roses (their indices are 1 and 2, and their total beauty is 7) and the only orange rose (its index is 3, its beauty is 4). This way the total beauty of the bouquet is 11.

In the second example Arkady can not buy a bouquet because all roses have the same color.

Codeforces (c) Copyright 2010-2018 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Oct/16/2018 01:31:59 (d3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|