Grigoriy, like the hero of one famous comedy film, found a job as a night security guard at the museum. At first night he received embosser and was to take stock of the whole exposition.

Embosser is a special devise that allows to "print" the text of a plastic tape. Text is printed sequentially, character by character. The device consists of a wheel with a lowercase English letters written in a circle, static pointer to the current letter and a button that print the chosen letter. At one move it's allowed to rotate the alphabetic wheel one step clockwise or counterclockwise. Initially, static pointer points to letter 'a'. Other letters are located as shown on the picture: [Image] 

After Grigoriy add new item to the base he has to print its name on the plastic tape and attach it to the corresponding exhibit. It's not required to return the wheel to its initial position with pointer on the letter 'a'.

Our hero is afraid that some exhibits may become alive and start to attack him, so he wants to print the names as fast as possible. Help him, for the given string find the minimum number of rotations of the wheel required to print it.


-----Input-----

The only line of input contains the name of some exhibit — the non-empty string consisting of no more than 100 characters. It's guaranteed that the string consists of only lowercase English letters.


-----Output-----

Print one integer — the minimum number of rotations of the wheel, required to print the name given in the input.


-----Examples-----
Input
zeus

Output
18

Input
map

Output
35

Input
ares

Output
34



-----Note-----

  [Image] 

To print the string from the first sample it would be optimal to perform the following sequence of rotations:   from 'a' to 'z' (1 rotation counterclockwise),  from 'z' to 'e' (5 clockwise rotations),  from 'e' to 'u' (10 rotations counterclockwise),  from 'u' to 's' (2 counterclockwise rotations).  In total, 1 + 5 + 10 + 2 = 18 rotations are required.

Difficulty: interview

Starter code:

Solutions:
now = "a"
ans = 0
S = input()
for s in S:
    x = abs(ord(s) - ord(now))
    ans += min(x, 26 - x)
    now = s
print(ans)


s = input()

cur = 'a'
total = 0

for k in s:
    c = abs(ord(cur) - ord(k))
    c = min(c, 26-c)
    cur = k
    total += c

print(total)

s = input()
S = "abcdefghijklmnopqrstuvwxyz"

ind = 0
ans = 0
for item in s:
    index = ind
    ans1 = 0
    while (S[index] != item):
        index = (index + 1) % 26
        ans1 += 1
    index = ind
    ans2 = 0
    while (S[index] != item):
        index = (index - 1 + 26) % 26
        ans2 += 1
    ans += min(ans1, ans2)
    ind = index
print(ans)


#!/usr/bin/env python3


def main():
    try:
        while True:
            s = input()
            cur = 0
            result = 0
            for c in s:
                c = ord(c) - 97
                result += min((c - cur) % 26, (cur - c) % 26)
                cur = c
            print(result)

    except EOFError:
        pass


main()


s=input()
alfabet="abcdefghijklmnopqrstuvwxyz"
rot=0
curr=0
for c in s:
    goto=alfabet.index(c)
    rot+=min(abs(goto-curr),abs(curr+26-goto),abs(curr-goto-26))
    curr=goto
print (rot)


def d(x,y):
    return min(abs(ord(x) - ord(y)),26-abs(ord(x)-ord(y)))

ans = 0
s = 'a'+input()
for i in range(len(s)-1):
    ans+=d(s[i],s[i+1])
print(ans)


s = input()
x = "abcdefghijklmnopqrstuvwxyz"
cur = "a"
ans = 0
for c in s:
    p = abs(x.find(cur) - x.find(c))
    p = min(p, 26 - p)
    ans += p
    cur = c
print(ans)


import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**10
mod = 10**9 + 7

def f():
    r = 0
    s = input()
    c = 0
    ai = ord('a')
    t = 0
    for si in s:
        sc = ord(si) - ai
        if sc > c:
            t = min(26+c-sc, sc-c)
        else:
            t = min(c-sc, sc+26-c)
        r += t
        c = sc
    return r

print(f())


__author__ = 'Think'
name=input()
prev="a"
total=0
for s in name:
	total+=min(abs(ord(s)-ord(prev)), 26-abs(ord(s)-ord(prev)))
	prev=s
print(total)

str = input()
res = 0
lastSmb = 0

for smb in str:
    sid = ord(smb) - ord('a')
    diff = sid - lastSmb
    if diff < 0:
        diff = -diff

    if diff > 13:
        diff = 26 - diff

    res += diff
    lastSmb = sid

print(res)

s = input()
n = 0
t = 'a'
for i in s:
    n+=min(abs(ord(i)-ord(t)), abs(26-abs(ord(i)-ord(t))))
    t = i
print(n)


def solve():
	s = input()
	prev = 0
	res = 0
	for c in s:
		now = ord(c) - ord('a')
		diff = abs(prev - now)
		diff = min(diff, 26 - diff)
		prev = now
		res += diff
	print(res)

solve()

# coding: utf-8

def count(i, g):
    cost = ord(g) - ord(i)
    if cost < 0:
        cost = 26 + cost
    if cost > 13:
        cost = 26 - cost
    return cost


s = input().strip()
i = "a"
cnt = 0
for c in s:
    cnt += count(i, c)
    i = c
print(cnt)


import sys
n=input()
koor=1
summa=0
for i in n:
    if (ord(i)-96)==koor:
        summa+=0
    else:
        summa+=min([abs(ord(i)-96-koor),26-abs(ord(i)-96-koor)])
        koor=ord(i)-96
print(summa)


NUM_OF_ALPHABET = ord('z') - ord('a') + 1
s = input()
total = 0
cur = 'a'
for c in s:
    total += min((ord(cur) - ord(c) + NUM_OF_ALPHABET) % NUM_OF_ALPHABET, (ord(c) - ord(cur) + NUM_OF_ALPHABET) % NUM_OF_ALPHABET)
    cur = c
print(total)


s = str(input())
s = s.strip()
res = 0;
aord = ord('a')
for i in (range(len(s))):
    t = abs(ord(s[i]) - aord)
    aord = ord(s[i])
    res = res + min(t, 26 - t)
print(res)

import string


s = input()

a = 'a'
ans = 0
for c in s:
    i = string.ascii_lowercase.index(c) - string.ascii_lowercase.index(a)
    i = abs(i)
    i = min(i, 26 - i)
    a = c
    ans += i

print(ans)


s = input()
b = 'abcdefghijklmnopqrstuvwxyz'
c = 0
now = 0

for i in range(len(s)):
    need = b.find(s[i])
    c += min(abs(now - need), abs(26 - abs(now - need)))
    now = need

print(c)

pointer = 0

s = input()
c = 0
for x in s:
    k = ord(x)-ord('a')
    crr = []
    if(k-pointer>=0):
        crr.append(k-pointer)
    else:
        crr.append(k-pointer+26)
    if(pointer-k>=0):
        crr.append(pointer-k)
    else:
        crr.append(pointer-k+26)
    pointer = k
    c += min(crr)
print(c)

#!/usr/bin/env python3

SEQ = 'abcdefghijklmnopqrstuvwxyz'

def dist(a, b):
  a = ord(a) - ord('a')
  b = ord(b) - ord('a')
  d = abs(a - b)
  return min(d, 26 - d)
  

def __starting_point():
  seq = input()
  pos = 'a'
  r = 0
  for c in seq:
    r += dist(pos, c)
    pos = c
  print(r)


__starting_point()

def solution():
    string = input()
    alphabet = "abcdefghijklmnopqrstuvwxyz"
    now = "a"
    res = 0
    for i in range(len(string)):
        d = abs(alphabet.find(now) - alphabet.find(string[i]))
        res += min(d, 26 - d)
        now = string[i]
    print(res)

solution()


s = input()
alphabet = dict(zip(list("abcdefghijklmnopqrstuvwxyz"), [i for i in range(1, 27)]))
summ = 0
cur_letter = 'a'
for letter in s:
    summ += min(abs(alphabet[letter] - alphabet[cur_letter]), 26 - abs(alphabet[letter] - alphabet[cur_letter]))
    cur_letter = letter
print(summ)

import sys, math

line = input()
length = len(line)
cur = 'a'
sumn = 0
for c in line:
	diff = abs(ord(c)-ord(cur))
	sumn += min(diff, 26 - diff)
	cur = c
print(sumn)


from sys import stdin


phrase=input()
lettreActuelle=0
total=0

for lettre in phrase:
    gauche=(ord(lettre)-ord("a")-lettreActuelle)%26
    droite=(lettreActuelle-ord(lettre)+ord("a"))%26
    rotation=min(gauche,droite)
    total+=rotation
    lettreActuelle=ord(lettre)-ord("a")

print(total)


import sys, math
a = 'abcdefghijklmnopqrstuvwxyz'
s = input()
pos = 0
vv = ord('a')
ans = 0
for i in s:
    gg = ord(i) - vv
    #print(25 - max(gg, pos) + min(pos, gg))
    ans += min(int(math.fabs(gg - pos)), 26 - max(gg, pos) + min(pos, gg))
    pos = gg
print(ans)