#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    string s;
    cin >> s;
    s = "A"+s;
    int ans = 0;
    for(int i=0; i<(int)s.length()-1; i++){
        if(s[i] >= s[i+1]) ans++;
    }
    cout << ans << endl;
    return 0;
}
