#include #include using namespace std; int minOperationsToGoodString(const string& S) { int balance = 0; int flips = 0; for (char ch : S) { if (ch == '1') { balance++; } else { balance--; } // If balance goes negative, flip a 0 to a 1 if (balance < 0) { flips++; balance += 2; // simulate flipping a 0 to a 1 } } return flips; } int main() { string S; cin >> S; cout << minOperationsToGoodString(S) << endl; return 0; }