import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
 
void main() {
	auto data = readln().split();
	auto S = data[0].to!string();
	auto first = S;
	if (first.length == 1) { writeln("0"); return; }
	
	string step(string s) {
		if (s.length == 0 || s.length == 1) return s;
		string result = "";
		ulong index = 0;
		while(true) {
			if (index == s.length-1) { result ~= s[$-1]; break; }
			if (index > s.length-1) { break; }
			if (s[index] != s[index+1]) {
				index += 2;
			}
			else {
				result ~= s[index]; index++;
			}
		}
		//writeln(result);
		return result;
	}
	
	while(true) {
		auto s = step(S);
		if (s.length == S.length) { writeln(first.length - S.length); break; }
		else { S = s; }
	}
	
}

string step(string s) {
	string result = "";	
	ulong index = 0;
	while (true) {
		if (index >= s.length-1) break;
		if (s[index] == s[index+1]) { index++; }
		else result ~= s[index];
		index++;
	}
	return result;
}