/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 2e5 + 10;

int main() {
	fast_cin();
	string t; cin >> t;
	int n = t.length();
	ll ans = 0;
	int k = 0, mx = 0, p = 0;
	vector<ll> c(2, 0);
	while (p < n and t[p] == '1') {
		++c[p & 1];
		++p;
	}
	mx = max(c[0], c[1]);
	while (p < n) {
		c[0] = c[1] = 0;
		++p;
		while (p < n and t[p] == '1') {
			++c[p & 1];
			++p;
		}
		ans += ((k + 2) / 2) * c[0] + ((k + 1) / 2) * c[1] + mx;
		mx += max(c[0], c[1]);
		++k;
	}
	int left = n - k;
	while (left) {
		ans += (left + 1) / 2;
		--left;
	}
	cout << ans << endl;
}