#include <bits/stdc++.h>
using namespace std;
#define S second
#define F first
#define LL long long
#define LINF 100000000000000000
#define INF 1000000000
const int N = 4e5+10;
const LL MOD = 1e9+7;
LL gcd(LL a,LL b){return !b?a:gcd(b,a%b);}
string f(int c,int k){
string ret = "";
for(int i=c;i<k;i++)
ret += i+'a',ret += c+'a';
return ret;
}
int main()
{
//freopen("out.txt","w",stdout);
string s;
cin>>s;
int ans = INF;
for(int i=0;i<26;i++){
int ans1 = 0;
for(char c:s)ans1 += abs(c-'a'-i);
ans = min(ans,ans1);
}
printf("%d\n",ans);
}
Copy