#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
inline int read()
{
	int res, ok = 1;
	char ch;
	for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar())
	if (ch == '-')
	ok = -1;
	res = ch - '0';
	for (ch = getchar(); ch >= '0' && ch <= '9'; ch = getchar())
	res = res * 10 + ch - '0';
	return res * ok;
}
char s[100005];
int n, cnt1, cnt2;
int main()
{
	scanf ("%s", s + 1);
	n = strlen (s + 1);
	for (int i = 1; i <= n; i++)
	if (s[i] == 'W' && s[i - 1] != 'W')
	cnt1++;
	for (int i = 1; i <= n; i++)
	if (s[i] == 'B' && s[i - 1] != 'B')
	cnt2++;
	printf ("%d\n", min (cnt1, cnt2));
	return 0;
}