#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < (n); i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

int n, acu, uno, cero;
string s, t;
ll res;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);

	cin >> t;
	n = t.size();

	for (char c : t) {
		if (c == '1') {
			if (s.size() && s.back() == c) {
				uno += 2;
				s.pop_back();
			} else {
				s.pb(c);
			}
		} else {
			cero++;
			s.pb(c);
		}
	}

	res += 1ll * cero * uno / 2;

	forn (i, s.size()) {
		if (s[i] == '1') {
			res += cero - acu + (acu + 1 - i % 2) / 2;
			uno++;
		} else {
			acu++;
		}
	}

	while (uno) {
		res += (uno + 1) / 2;
		uno--;
	}

	cout << res << endl;

	return 0;
}