#include <bits/stdc++.h>
using namespace std;
std::vector<int> find_all(const std::string str, const std::string subStr) {
  std::vector<int> result;
  int subStrSize = subStr.size();
  int pos = str.find(subStr);
  while (pos != std::string::npos) {
    result.push_back(pos);
    pos = str.find(subStr, pos + subStrSize);
  }
  return result;
}
map<string, int> reduce_memo{
    {"", 0},
    {"1", 0},
    {"0", 0},
};
int reduce(const string str) {
  if (reduce_memo.count(str) > 0) {
    return reduce_memo[str];
  }
  auto targets = find_all(str, "01");
  auto targets2 = find_all(str, "10");
  targets.insert(targets.end(), targets2.begin(), targets2.end());
  if (targets.size() == 0) {
    return 0;
  } else {
    int max_index = -1;
    int max_result = -1;
    set<string> calced;
    for (const int index : targets) {
      string tmp(str);
      tmp.replace(index, 2, "");
      if (calced.count(tmp) > 0) {
        continue;
      }
      calced.insert(tmp);
      auto result = reduce(tmp) + 2;
      if (max_result < result) {
        max_index = index;
        max_result = result;
      }
    }
    if (max_index < 0) {
      cout << "Not Implemented" << endl;
      return -1;
    }
    reduce_memo[str] = max_result;
    return max_result;
  }
}
int main(void) {
  string str;
  cin >> str;
  auto result = reduce(str);
  cout << result << endl;
  return 0;
}
