We’re preparing your current view and syncing the latest data.
You are given a sequence of pebbles, each painted with one of three colors: R (red), G (green), or B (blue). The cost to paint a pebble of one color into another color is given. The task is to find the minimum total cost to make all the pebbles be the same color.
The first line contains three integers representing the cost to paint R→G, G→B, and B→R respectively. The next line contains a string denoting the sequence of pebble colors.
Print the minimum total cost to make all the pebbles have the same color.
The sequence length can be up to 50 characters.
Example 1
Input
5 9 4 RRGBBB
Output
15
Explanation
Convert all pebbles to R color with minimum cost.