#include using namespace std; #define rep(i,n) for(int i = 0; i < (n);i++) #define sz(x) int(x.size()) typedef long long ll; typedef long double ld; typedef pair P; constexpr int INF = 2e9; int main() { string s; cin >> s; s = '0' + s; reverse(s.begin(), s.end()); int n = s.size(); vector> dp(n + 1, vector(2, INF)); dp[0][0] = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < 2; j++) { int d = s[i] - '0'; int now = d + j; int nj = 0; if (now == 2) { now = 0; nj = 1; } if (!now) dp[i + 1][nj] = min(dp[i + 1][nj], dp[i][j]); else { dp[i + 1][nj] = min(dp[i + 1][nj], dp[i][j] + 1); if (!nj) dp[i + 1][nj + 1] = min(dp[i + 1][nj + 1], dp[i][j] + 1); } } } cout << dp[n][0] << endl; return 0; }