#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,tune=native")
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  string backup = s;
  auto i = s.find("01", 0);
  while (i != -1) {
    s = s.substr(0, i) + s.substr(i + 2, -1);
    i = s.find("01", 0);
  }
  i = s.find("10", 0);
  while (i != -1) {
    s = s.substr(0, i) + s.substr(i + 2, -1);
    i = s.find("10", 0);
  }
  cout << backup.length() - s.length();
  return 0;
}
