#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
  string p;
  cin >> p;
  int n = p.size();
  char s[110000];
  for (int i = 0; i < (n); i++) {
    s[i + 1] = p[i];
  }
  s[0] = '5';
  s[n + 1] = '5';
  int rennsa = 0;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    rennsa = 0;
    if (s[i] == '0' && s[i + 1] == '1' || s[i] == '1' && s[i + 1] == '2') {
      while (s[i - rennsa] == '0' && s[i + 1 + rennsa] == '1' ||
             s[i - rennsa] == '1' && s[i + 1 + rennsa] == '0') {
        rennsa++;
        ans += 2;
      }
      i += rennsa;
    }
  }
  cout << ans << endl;
  return 0;
}
