In the world of high-speed racing, only the most skilled competitors can navigate the treacherous track to reach the finish line in record time. You are one such racer, aiming to win the prestigious "Ace Race" by reaching the goal as fast as possible.
The race track is a straight path with $$$N$$$ cells, numbered from $$$1$$$ to $$$N$$$ from left to right. You start the race at cell $$$1$$$, and your goal is to reach cell $$$N$$$. You can move to adjacent cells at any time, where cell $$$x$$$ is adjacent to cells $$$x-1$$$ and $$$x+1$$$. Normally, moving from cell $$$x$$$ to cell $$$x+1$$$ or $$$x-1$$$ takes $$$2$$$ seconds.
Along the track, some cells contain powerups that can either help or challenge your progress. Your task is to strategize the use of these powerups and determine the fastest way to reach the finish line.
There are three possible types of cells:
As the racer, you have complete control over which powerups to use. If you land on a Speed Boost or Jump Pad cell, you may choose whether or not to activate the powerup. Importantly, you have the option to activate the powerup each time you land on the cell, meaning the same powerup can be used multiple times if you return to that cell during your race.
Your challenge is to reach cell $$$N$$$ in the minimum possible time.
The first line contains a single integer $$$N$$$ ($$$2 \leq N \leq 10^5$$$), the number of cells on the race track.
The next $$$N$$$ lines contain the info for each cell. The $$$i$$$-th line describes cell $$$i$$$, it starts with a single uppercase letter $$$C_i$$$, describing the type of the cell $$$i$$$:
Output a single integer: the minimum time (in seconds) required to reach cell $$$N$$$.
8J 5XJ 8XS 2XXX
4
7XXS 2S 1XJ 1X
10
Consider sample 1, the optimal path is as follows:
The time required to reach the goal is 4 seconds with this path. It can be proven that it is not possible to reach the goal in a shorter time.
| Name |
|---|


