Keyboard

Everyone is familiar with the QWERTY keyboard layout:

QWERTYUIOP
ASDFGHJKL 
ZXCVBNM   

Cosmin is new to the world of computers and technology. He is currently learning to type on a keyboard, by using only his two index fingers. Today, he is practicing his new skill by typing a non-empty sequence of uppercase English letters.

Initially, Cosmin places his left index finger on F and his right index finger on J. At each point in time, he chooses one of his fingers, moves it to the next letter in the sequence, and presses that particular key. The cost of doing so is equal to the Manhattan distance between the old and the new position of his finger.

Your task is to find the minimum total cost of typing the entire sequence.

Input

The first line of input contains the letter sequence.

Output

A single integer: the minimum total cost of typing the entire sequence.

Constraints

  • The sequence contains at most 100 letters.

Samples

InputOutputExplanation
FFJJJFJFJFJ0 Cosmin doesn't even need to lift his fingers to type this.
QKL6
  • Cosmin moves his left finger from F to Q (cost = 4)
  • Then, he moves his right finger from J to K (cost = 1)
  • Finally, he moves his right finger from K to L (cost = 1)
Questions?

Sponsors Gold