#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int firstLength = s.length();
  string replacement = "";
  while (true) {
    string::size_type pos = 0;
    if ((pos = s.find("01", pos)) != string::npos) {
      s.replace(pos, 2, replacement);
    }
    pos = 0;
    if ((pos = s.find("10", pos)) != string::npos) {
      s.replace(pos, 2, replacement);
    }
    pos = 0;
    if ((pos = s.find("01", pos)) == string::npos &&
        (pos = s.find("10", pos)) == string::npos) {
      break;
    }
  }
  cout << firstLength - s.length();
}
