#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  ;
  string s;
  int i, r = 0, b = 0, cnt = 0, f = -1;
  cin >> s;
  vector<pair<int, int>> cols;
  for (i = 0; i < s.size(); i++) {
    if (s[i] == '0')
      r++;
    else
      b++;
    if (s[i] == '0') {
      if (f == -1) {
        f = 0;
        cnt = 1;
      } else if (f == 0)
        cnt++;
      else {
        cols.push_back(make_pair(cnt, f));
        f = 0;
        cnt = 1;
      }
    } else {
      if (f == -1) {
        f = 1;
        cnt = 1;
      } else if (f == 1)
        cnt++;
      else {
        cols.push_back(make_pair(cnt, f));
        f = 1;
        cnt = 1;
      }
    }
  }
  cols.push_back(make_pair(cnt, f));
  while (cols.size() >= 2) {
    if (cols[0].second != cols[1].second) {
      if (cols[0].first >= cols[1].first) {
        cols[0].first -= cols[1].first;
        cols.erase(cols.begin() + 1);
      } else {
        cols[1].first -= cols[0].first;
        cols.erase(cols.begin());
      }
    } else {
      cols[0].first += cols[1].first;
      cols.erase(cols.begin() + 1);
    }
  }
  cout << s.size() - cols[0].first << '\n';
}
