#include #define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++) #define rep(i, begin, end) for(int i = int(begin); i < int(end); i++) #define all(v) v.begin(), v.end() #define lint long long auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;}; auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;}; void debug_impl() { std::cerr << std::endl; } template void debug_impl(Head head, Tail... tail){ std::cerr << " " << head; debug_impl(tail...); } #define debug(...)\ std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\ debug_impl(__VA_ARGS__);\ std::cerr << std::noboolalpha; int main() { std::cin.tie(0); std::cin.sync_with_stdio(false); std::string s; std::cin >> s; std::string t; auto x = 2, y = 0, z = 0; int nx = 0, ny = 0, nz = 0; constexpr int inf = 1'000'000'000; for (auto c : s) { t.push_back(c); if (c == '0') { nx = x + 1; ny = inf; nz = std::min({x, y, z}); } else { nx = x; ny = std::min({x, y, z}) + 1; nz = inf; } cmn(nx, inf); cmn(ny, inf); cmn(nz, inf); std::swap(x, nx); std::swap(y, ny); std::swap(z, nz); // debug(x, y, z, t); } std::cout << std::min({x, y, z}) << std::endl; return 0; }