Source Code
#include <iostream>
using namespace std;

int main() {
    string s;
    int ans = 0;
    cin>>s;
    for(int i = 0; i<s.length(); i++){
        if(s[i]=='1'){
            ans++;
        }else if(s[i]=='0' && s[i-1]=='1' && s[i+1]== '1'){
            ans++;
        }else{
            continue;
        }
       
        }cout<<ans;
    return 0;
    }
Copy
Japanese holidays osaidz7
GNU G++17
5 ms
1.1 MB
Accepted