是时候放松一下,做一道简单的题目了

Walking

Orange Boy loves walking. One day, he wanna walk from to

the boy can walk in three types:

  1. from to by costing A yuan

  2. from to by costing B yuan

  3. from to or by costing C yuan

He must walk from to then from to and so on and reaches

What's the minimal cost???!!?!

Examples

Input
A,B,C=2,3,4
(1,1)->(3,3)->(2,2)->(4,3)

Output
18

Explain
Path is this:
(1,1) -> (2,2) -> (3,3) -> (2,2) -> (3,3) -> (4,3)
Cost=4+4+4+4+2=18

note that he must visit them in order.

Constriants

Subtask 1(100%):