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


