#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  char prev = s[0], now;
  int cnt = 1;
  for (int i = 1; i < s.size(); i++) {
    now = s[i];
    if (now != prev) {
      cnt++;
      prev = now;
    } else {
      cnt--;
      if (cnt > 0) {
        if (prev == '0') {
          prev = '1';
        } else {
          prev = '0';
        }
      } else {
        prev = '2';
      }
    }
  }
  cout << s.size() - cnt << endl;
}
