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

const int maxn = 1000010;
int n, num;
char s[maxn];
long long ans;

int main() {
    scanf("%s", s + 1), n = strlen(s + 1);
    for (int i = 1; i <= n; i++) {
        if (s[i] == '0') num++;
    }
    int cur0 = 0, cur1 = 0;
    for (int i = 1; i <= n; i++) {
        if (s[i] == '0') {
            cur0++;
        } else {
            cur1++;
            if (s[i + 1] == '1') {
                ans += num + 1;
                cur1++, i++;
            } else {
                ans += num - cur0;
                if (i & 1) ans += (cur0 + 2) >> 1;
                else ans += (cur0 + 1) >> 1;
            }
        }
    }
    for (int i = 1; i < cur1; i++) ans += (i + 1) >> 1;
    printf("%lld\n", ans);
    return 0;
}