#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int len = s.size();
  string::size_type pos = s.find("01");
  while (pos != string::npos) {
    s.replace(pos, 2, "");
    pos = s.find("01");
  }
  pos = s.find("10");
  while (pos != string::npos) {
    s.replace(pos, 2, "");
    pos = s.find("10");
  }
  pos = s.find("01");
  while (pos != string::npos) {
    s.replace(pos, 2, "");
    pos = s.find("01");
  }
  cout << len - s.size() << endl;
}
