import std.stdio;
import std.string;
import std.algorithm;

void main() {
	auto s = readln.chomp;
	char current = '\0';
	size_t cnt;
	size_t max_cnt;
	foreach(c; s) {
		if (c != current) {
			max_cnt = max(max_cnt, cnt);
			cnt = 1;
		}
		else {
			++cnt;
		}
		current = c;
	}
	write(s.length - max_cnt);
}
