#include <bits/stdc++.h>
using namespace std;
int one_pass(const string& s, string& s_c) {
  int q1 = 0;
  int q2 = 0;
  int output = 0;
  int len = s.size();
  char type1 = ' ';
  char type2 = ' ';
  int l;
  int j;
  vector<pair<int, int>> del_lst;
  for (int i = 0; i < len; i++) {
    char debug = s[i];
    if (q1 == 0) {
      type1 = s[i];
      type2 = s[i] == '0' ? '1' : '0';
    }
    if (q2 == 0) {
      if (s[i] == type1) {
        q1++;
      } else {
        q2++;
      }
    } else {
      if (s[i] == type2) {
        q2++;
      } else {
        l = min(q1, q2) * 2;
        del_lst.push_back({i - (q1 + q2) + 1, l});
        output += l;
        q1 = 1;
        q2 = 0;
        type1 = s[i];
        type2 = s[i] == '0' ? '1' : '0';
      }
    }
    j = i;
  }
  l = min(q1, q2) * 2;
  del_lst.push_back({j - (q1 + q2) + 1, l});
  output += l;
  len = del_lst.size();
  pair<int, int> i_l;
  int i_s;
  for (int i = 0; i < len; i++) {
    i_l = del_lst.back();
    del_lst.pop_back();
    s_c.erase(i_l.first, i_l.second);
  }
  return output;
}
int main() {
  string s;
  s.reserve(1e5);
  cin >> s;
  int output = 0;
  int pass_output = -1;
  while (pass_output != 0) {
    string s_c = s;
    pass_output = one_pass(s, s_c);
    s = s_c;
    output += pass_output;
  }
  cout << output << endl;
  return 0;
}
