#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;




int main(){
    string T;
    cin >> T;

    Int N;
    N = T.size();

    vector<Int> zeros, ones;
    Int numof0 = 0, numof1 = 0, temp0 = 0, temp1 = 0;

    if (T[0] == '1') zeros.push_back(0);
    rep(i,N - 1) {
        if (T[i] == '0') {
            numof0++;
            temp0++;
            if (T[i+1] == '1') {
                zeros.push_back(temp0);
                temp0 = 0;
            }
        }
        else {
            numof1++;
            temp1++;
            if (T[i+1] == '0') {
                ones.push_back(temp1);
                temp1 = 0;
            }
        }
    }

    if (T[N-1] == '0') {
        numof0++;
        temp0++;
        zeros.push_back(temp0);
    }
    else {
        numof1++;
        temp1++;
        ones.push_back(temp1);
    }


    //試しに
    //rep(i,zeros.size()) cout << zeros[i] << endl;

    Int ans = 0;

    if (numof0 == 0) {
        Int y = numof1 / 2;
        if (numof1 % 2 == 0) {
            ans += y * (y + 1);
        }
        else {
            ans += (y + 1) * (y + 1);
        }
        cout << ans << endl;
        return 0;
    }
    if (numof1 == 0) {
        cout << 0 << endl;
        return 0;
    }

    rep(i, ones.size()) {
        ans += (numof0 + 1) * (ones[i] / 2);
    }

    //cout << ans << endl;

    Int x = numof1 / 2;
    if (numof1 % 2 == 0) {
        ans += x * x;
    }
    else {
        ans += (x + 1) * x;
    }

    //cout << ans << endl;


    bool flag = true;
    rep(i,ones.size()) {
        if (ones[i] % 2 == 1) flag = false;
    }
    if (flag) {
        cout << ans << endl;
        return 0;
    }


    vector<Int> essones, esszeros;





    //if (T[0] == '0') {
        esszeros.push_back(zeros[0]);
        rep1(i,zeros.size()-1) {
            if (ones[i-1] % 2 == 0) {
                esszeros[esszeros.size()-1] += zeros[i];
            }
            else {
                esszeros.push_back(zeros[i]);
            }
        }
        if (T[N-1] == '1') {
            if (ones[ones.size()-1] % 2 == 1) esszeros.push_back(0);
        }

        //試しに
        //rep(i,esszeros.size()) cout << esszeros[i] << endl;

        Int sumess0 = 0;
        rep(i,esszeros.size() - 1) {
            sumess0 += esszeros[i];
            ans += numof0 + 1;
            if (sumess0 % 2 == 0 && i % 2 == 0) {
                ans -= (sumess0 + 1) / 2;
            }
            if (sumess0 % 2 == 1 && i % 2 == 0) {
                ans -= (sumess0 + 1) / 2;
            }
            if (sumess0 % 2 == 0 && i % 2 == 1) {
                ans -= (sumess0 + 2) / 2;
            }
            if (sumess0 % 2 == 1 && i % 2 == 1) {
                ans -= (sumess0 + 1) / 2;
            }
        }
    //}

    cout << ans << endl;
}