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