#include<bits/stdc++.h>
using namespace std;
int main()
{
 string s;
  cin>>s;
  int count=0,ans=0;
  for(int i=0;i<s.length()-1;i++)
  {
    if(s[i]==s[i+1])
      count++;
    if(ans<count)
      ans=count;
    if(s[i]!=s[i+1])
      count=0;
    
    
  }
  cout<<(s.length-ans);
  
  
}