#include <bits/stdc++.h>
const long long MOD = 1000000007;
const long long INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<long long, long long> fd[] = {make_pair(1, 0), make_pair(-1, 0),
                                         make_pair(0, 1), make_pair(0, -1)};
signed main() {
  string s;
  cin >> s;
  vector<long long> v(s.length());
  for (long long i = (0); i < (s.length()); i++) {
    if (s[i] == '1')
      v[i] = 1;
    else
      v[i] = -1;
  }
  for (long long i = (1); i < (v.size()); i++) v[i] += v[i - 1];
  long long ans = -1;
  for (long long i = (0); i < (v.size()); i++) {
    if (!v[i]) ans = i;
  }
  cout << ans + 1 << endl;
}
