#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  string replaced_s = regex_replace(s, regex("01|10"), "");
  string tmp_s;
  while (replaced_s != tmp_s) {
    tmp_s = replaced_s;
    replaced_s = regex_replace(replaced_s, regex("01|10"), "");
  }
  int diff = int(s.size() - replaced_s.size());
  printf("%d\n", diff);
  return 0;
}
