#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
std::string replaceStringAll(std::string str, const std::string& replace,
                             const std::string& with) {
  if (!replace.empty()) {
    std::size_t pos = 0;
    while ((pos = str.find(replace, 0)) != std::string::npos) {
      str.replace(pos, replace.length(), with);
    }
  }
  return str;
}
int main() {
  string S = "0011";
  cin >> S;
  auto ret = replaceStringAll(S, "01", "");
  ret = replaceStringAll(ret, "10", "");
  cout << S.size() - ret.size() << endl;
  return 0;
}
