#include <bits/stdc++.h>
using namespace std;
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
int main() {
  int count = 0;
  int count2 = 0;
  string s;
  cin >> s;
  int n = s.length();
  string target = "01";
  string replacement = "";
  if (!target.empty()) {
    std::string::size_type pos = 0;
    while ((pos = s.find(target, pos)) != std::string::npos) {
      s.replace(pos, target.length(), replacement);
      pos += replacement.length();
      count++;
    }
  }
  string target2 = "10";
  string replacement2 = "";
  if (!target2.empty()) {
    std::string::size_type pos = 0;
    while ((pos = s.find(target2, pos)) != std::string::npos) {
      s.replace(pos, target2.length(), replacement2);
      pos += replacement.length();
      count2++;
    }
  }
  if (s[0] == '1' || s[1] == '0') count2 = count2 + 1;
  if (s[n - 1] == '0' || s[n] == '1') count = count + 1;
  cout << 2 * (count + count2) << endl;
}
