#include using namespace std; using lint = long long; template using V = vector; template using VV = V< V >; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); string s; cin >> s; int n = s.size(); int z = 0, o = 0; int res = 0; V<> v; for (int i = 0; i < n; ++i) { if (s[i] == '0') { ++z, o = 0; } else { ++o, z = 0; } if (s[i] == s[i + 1]) continue; if (o) { v.push_back(o); if (i + 2 >= n or s[i + 2] == '0') { if (count(begin(v), end(v), 1) == (int)v.size()) { res += v.size(); } else { res += v.size() + 1; } V<>().swap(v); } } } cout << res << '\n'; }