#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <math.h>
#define pairi pair <int,int>
#define pairll pair <long long,long long>
#define vi vector <int>
#define vll vector <long long>
#define mapi map <int,int>
#define mapill map <int,long long>
#define seti set <int>
#define setll set <long long>
#define pb push_back
#define fr(i,a,b) for(int i = a ; i < b ; i++)
#define fir(i,a,b) for(int i = b ; i >= a ; i--)
typedef long long ll ;
using namespace std;
int main()
{
int t , n , i , k , *a ;
string s ;
cin >> s ;
n = s.length() ;
map <char,int> ch ;
for(char c : s)
ch[c]++ ;
int temp = 10000000 ;
for(auto x : ch)
{
int ans = 0 ;
for(auto m : ch)
ans += abs(x . first - (m.first)) * (m.second) ;
temp = min(temp,ans) ;
}
cout << temp << endl ;
}
Copy