There are cells in a row. Each cell contains one card whose color is or .
Switch lies between cells and and has operating cost .
Every switch can be operated exactly once. Operating a switch that has not been used performs the following actions in order:
All switches must be operated exactly once. Find the minimum total cost over all operating orders.
The input is given in the following format:
For each test case, print the minimum total cost of operating every switch exactly once.
Operating the switches in the order gives total cost .
Each case is given in the following format:
is the initial color of the card in cell .
| 76 |
No additional constraints. |