#include <bits/stdc++.h>
int main() {
  int count = 0;
  std::string S;
  std::cin >> S;
  std::regex r = std::regex("(0{3}1{3}|1{3}0{3}|0{2}1{2}|1{2}0{2}|01|10)");
  std::string buf = "";
  while (S != buf) {
    buf = S;
    S = std::regex_replace(S, r, "");
    count += (buf.size() - S.size());
  }
  std::cout << count << std::endl;
  return 0;
}
