typedef long long ll; #include using namespace std; int main() { string s; std::cin >> s; ll n = s.length(); vector cnt; ll ren0 = 0; ll ren1 = 0; for (int i = 0; i < n; i++) { if(s[i]=='1'){ if(ren0==0){ ren1++; }else{ cnt.push_back(ren0); ren0=0; ren1=1; } }else{ if(ren1==0){ ren0++; }else{ cnt.push_back(ren1); ren1=0; ren0=1; } } } ll ans = 0; cnt.push_back(max(ren0,ren1)); for (int i = 0; i < cnt.size(); i++) { if(i%2==0){ // 押し付けられるなら if(i2 && cnt[i-1]==1 && cnt[i-2]>1)ans++; ans++; }else{ ans+=2; } } } } std::cout << ans << std::endl; }