#include <bits/stdc++.h>
using namespace std;
string cut(string s) {
  if (s == "01" || s == "10") return "";
  for (int i = 0; i < s.length(); ++i) {
    string part = s.substr(i, 2);
    if (part == "01" || part == "10") {
      s = s.substr(0, i) + s.substr(i + 2, s.length());
    }
  }
  return s;
}
int main() {
  string s;
  cin >> s;
  int size = s.length();
  string m = cut(s);
  int after = m.length();
  while (1) {
    m = cut(m);
    int after2 = m.length();
    if (after == after2) break;
    after = after2;
  }
  cout << (size - after) << endl;
}
