#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<algorithm>

using namespace std;
const int maxn = 100000+5;
int n,f[maxn],g[maxn];
char S[maxn];

int main(){
	int i,j;
	scanf("%s",S+1);
	n = strlen(S+1);
	for(i=2;i<=n;i++)
		f[i] = S[i] == S[i-1] ? f[i-1]:f[i-1]+1;
	for(i=n-1;i>0;i--)
		g[i] = S[i] == S[i+1] ? g[i+1]:g[i+1]+1;
	int ans = 0x3f3f3f3f;
	for(i=1;i<=n;i++)
		ans = min(f[i]+g[i],ans);
	cout<<ans<<endl;
	return 0;
}