#include <bits/stdc++.h>
using namespace std;
vector<int> a(100010);
int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); ++i) {
    a[i] = s[i] - '0';
  }
  a[s.size()] = 9;
  int before;
  int after;
  int count = 0;
  do {
    before = a.size();
    for (int i = 0; i < a.size(); ++i) {
      if (a[i] == 9) break;
      if (i != 0 && a[i] != a[i - 1] && a[i - 1] != 3) {
        a[i] = a[i - 1] = 3;
        count += 2;
      }
    }
    a.erase(remove_if(a.begin(), a.end(), [](int n) { return 3 == n; }),
            a.end());
    after = a.size();
  } while (before != after);
  cout << count;
}
