#include using namespace std; using ll = long long; #define FOR(i, m, n) for (int i = (m); i < (n); i++) #define REP(i, n) FOR(i, 0, n) #define REP1(i, n) FOR(i, 1, (n) + 1) #define ALL(c) (c).begin(), (c).end() template inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;} template inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;} const int MOD = 1000000007; const int INF = 1000000001; int main() { string s; cin >> s; int c = 0; // eating 1 REP(i, s.size()) { if (s[i] == '1') c++; } // filling 0 -> +1 > eat int d = 0; REP(i, s.size()) { if (s[i] == '0') d++; } d += 2; reverse(ALL(s)); int e = 0; bool r = false; REP(i, s.size()) { if (s[i] == '0') { if (r) { e++; } } else { if (!r) { e++; r = true; } } } e++; reverse(ALL(s)); int f = 0; s += "0"; size_t p; int q = 0; while ((p = s.find("0010", q)) != string::npos) { q = (int)p; s[q + 2] = '0'; f++; } bool z = false; bool o = false; REP(i, s.size()) { if (s[i] == '1') { if (!o) { o = true; f += (z ? 2 : 1); } } else { if (o) { o = false; z = false; } else { z = true; } } } f++; cout << min({c, d, e, f}) << endl; }