Source Code
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main(){
	string s;
	cin >> s;
	int counter = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == '1'){
			counter++;
		}
		else if(i == 0 || i == s.size() - 1){
			continue;
		}
		else{
			if(s[i - 1] == '1' && s[i + 1] == '1'){
				counter++;
			}
		}
	}
	cout << counter;
}
Copy
Japanese holidays Rokii
GNU G++17
5 ms
1.0 MB
Accepted