#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; using Pll = pair; using Pii = pair; constexpr ll MOD = 1000000007; constexpr long double EPS = 1e-10; constexpr int dyx[4][2] = { { 0, 1}, {-1, 0}, {0,-1}, {1, 0} }; int main() { std::ios::sync_with_stdio(false); cin.tie(nullptr); string s; cin >> s; int n = s.length(); vector a(n+1, 0), ones(n+1, 0); for(int i=0;i> dp(n+1, vector(2, 0)); dp[0][0] = a[0]; dp[0][1] = 1-a[0]; for(int i=1;i<=n;++i) { if(a[i]) { dp[i][0] = dp[i-1][0] + 1; dp[i][1] = min(dp[i-1][0], dp[i-1][1]); } else { dp[i][0] = min(dp[i-1][0], dp[i-1][1] + 2); dp[i][1] = min(dp[i-1][0], dp[i-1][1]) + 1; } // cerr << i << ": " << dp[i][0] << ", " << dp[i][1] << endl; } cout << dp[n][0] << endl; }