#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> S(100005, 2);
  for (int i = 0; i < 100005; i++) {
    char a = '!';
    cin >> a;
    if (a == '0') {
      S[i] = 0;
    } else if (a == '1') {
      S[i] = 1;
    }
  }
  int N = 100005;
  vector<int> K;
  int i = 0;
  while (i < N) {
    K.push_back(0);
    if (S.at(i) == 0) {
      while (i < N && S[i] == 0) {
        K[K.size() - 1]++;
        i++;
      }
    } else if (S.at(i) == 1) {
      while (i < N && S[i] == 1) {
        K[K.size() - 1]++;
        i++;
      }
    } else {
      K.pop_back();
      i = N;
    }
  }
  int ans = 0;
  while (i != 0) {
    i = 0;
    for (int j = 0; j < K.size() - 1; j++) {
      if (K[j] == 0 && K[j + 1] == 0) {
        K.erase(K.begin() + j);
        K.erase(K.begin() + j);
        i = 1;
      } else if (K[j] != 0 && K[j + 1] != 0) {
        if (K[j] > K[j + 1]) {
          N = K[j + 1];
        } else {
          N = K[j];
        }
        K[j] -= N;
        K[j + 1] -= N;
        ans += 2 * N;
        i = 1;
      }
    }
  }
  cout << ans << endl;
}
