#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
int count=0,now=97;
for(int i=0;i<s.size();i++)
{
int t=s[i];
int temp =abs(t-now);
// cout<<t<<" "<<temp<<endl;
if(temp>13)
{
count += (13-(abs(t-now)-13));
// cout<<s[i]<<"for1 : "<<(abs(t-now)-13)<<endl;
}
else{
count +=abs(t-now);
// cout<<s[i]<<"for2 : "<<(abs(t-now))<<endl;
}
now = t;
}
cout<<count<<endl;
}
Add your comment