#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
int ans;
int main(){
  string s;
  cin>>s;
  if(s[0]=='A')ans++;
  r(i,s.size()-1)
    if(s[i]>=s[i+1]) ans++;
  cout<< ans <<endl;
}