#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	const int n = s.size();
	if(s == string(n, '0')){
		cout << 0 << endl;
		return 0;
	}
	vector<bool> select(n);
	const int first = find(s.begin(), s.end(), '1') - s.begin();
	select[first] = true;
	for(int i = first + 1; i + 1 < n; ){
		if(s[i + 1] == '0'){
			++i;
		}else{
			select[i] = select[i + 1] = true;
			i += 2;
		}
	}
	ll answer = 0, pos = 0, k00 = 0, k01 = 0, k10 = 0, k11 = 0;
	for(int i = 0; i < n; ++i){
		if(!select[i]){ continue; }
		if(pos % 2 == 0){
			k01 += s[i] - '0';
		}else{
			k00 += s[i] - '0';
		}
		answer += k01;
		++pos;
	}
	for(int i = n - 1; i >= 0; --i){
		if(select[i]){
			--pos;
			if(s[i] == '1'){
				if(pos % 2 == 0){
					--k01;
					++k11;
				}else{
					--k00;
					++k10;
				}
			}
		}else{
			swap(k10, k11);
			if(s[i] == '1'){
				if(pos % 2 == 0){
					++k11;
				}else{
					++k10;
				}
			}
			answer += k01 + k11;
		}
	}
	cout << answer << endl;
	return 0;
}

