#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_cxx;

typedef double db;
typedef long long ll;
typedef pair<db, db> pdd;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef unsigned long long ull;

#define F          first
#define S          second
#define pnl        printf("\n")
#define sz(x)      (int)x.size()
#define sf(x)      scanf("%d",&x)
#define pf(x)      printf("%d\n",x)
#define all(x)     x.begin(),x.end()
#define rall(x)    x.rbegin(),x.rend()
#define rep(i, n)  for(int i = 0; i < n; ++i)

const db eps = 1e-9;
const db pi = acos(-1);
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1000 * 1000 * 1000 + 7;

string str;
string alph = "abcdefghijklmnopqrstuvwxyz";
int dp[55][55];

int solve(int i, int j) {
    if (i == sz(str) || j == sz(alph))
        return 0;
    int &ret = dp[i][j];
    if (~ret) return ret;
    ret = max(solve(i + 1, j), solve(i, j + 1));
    if (str[i] == alph[j])
        ret = max(ret, solve(i + 1, j + 1) + 1);
    return ret;
}

int main() {
    cin >> str;
    memset(dp, -1, sizeof dp);
    cout << (26 - solve(0, 0)) << endl;
    return 0;
}
