#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int CountTab[32]={1,2,3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3,4,1,2,3,0,1,2,3,4};
char LetterTab[32]={'a','b','c',' ','d','e','f',' ','g','h','i',' ','j','k','l',
                 ' ','m','n','o',' ','p','q','r','s','t','u','v',' ','w','x','y','z'};
int main() {
    string str;
    int time;
    while(cin>>str){
        time=0;
        int temp=0;
        for(int i=0;i<str.size();++i){
            int j=0;
            while(LetterTab[j]!=str[i]){
                ++j;
            }
            time+=CountTab[j];
            if(j/4==temp/4){
                time+=2;
            }
            temp=j;
        }
        if(str[0]=='a'||str[0]=='b'||str[0]=='c'){
            time-=2;
        }
        cout<<time<<endl;
    }
	return 0;
}