#include <bits/stdc++.h>
using namespace std;
struct Setup {
  Setup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
};
int main() {
  Setup();
  string S;
  cin >> S;
  const int len = S.size();
  vector<int> acc(len + 1);
  acc[0] = 0;
  int zero_pos = 0;
  for (int i = 1; i <= len; i++) {
    acc[i] = acc[i - 1] + (S[i - 1] == '0' ? -1 : 1);
    if (acc[i] == 0) {
      zero_pos = i;
    }
  }
  cout << zero_pos << endl;
}
