#include using namespace std; int main(void){ string S; cin >> S; S += '0'; vector>> n; int cnt = 0; int s; int t; int l = 0; for (int i = 0; i < S.length(); i++) { if (S[i] == '1') { if (l == 0) s = i; l++; } else { if (l > 0) { t = i-1; n.push_back({l, {s, t}}); } l = 0; } } long long ans = 0; for (int i = n.size() - 1; i >= 0; i--) { auto p = n[i]; int l = p.first; int s = p.second.first; int t = p.second.second; if (l == 1) { ans++; } else if (i != 0 && n[i-1].second.second + 2 == s) { ans++; n[i-1].first++; n[i-1].second.second++; } else { ans += 2; } } cout << ans << endl; }