Kkung just set the high score on a favorite game! Only the name is left to enter, and the entry pad makes that a chore.
Say the name is 'ALMA'. Kkung can enter it like this.
| Action | Presses | Name so far (| = cursor) | Letter to enter |
|---|---|---|---|
| FIRE | 1 | A| | A |
| UP | 11 | A| | L |
| FIRE | 1 | AL| | L |
| UP | 1 | AL| | M |
| FIRE | 1 | ALM| | M |
| DOWN | 12 | ALM| | A |
| FIRE | 1 | ALMA| | A |
That costs 28 presses. Now look at this run instead.
| Action | Presses | Name so far (| = cursor) | Letter to enter |
|---|---|---|---|
| FIRE | 1 | A| | A |
| FIRE | 1 | AA| | A |
| LEFT | 1 | A|A | A |
| UP | 11 | A|A | L |
| FIRE | 1 | AL|A | L |
| UP | 1 | AL|A | M |
| FIRE | 1 | ALM|A | M |
That finishes the same name in 17 presses. Given a name, how few button presses are enough to enter it? The letter to enter starts at A, and the cursor may sit anywhere once the name is complete.
Each test case is one line holding a name made only of uppercase letters, with length between 1 and 18. The last line of the input holds a single 0.
For each test case, print the smallest number of button presses that enters the name, one per line.