#include #include using namespace std; using namespace atcoder; using ll = long long; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } ll inf_ll = 9223372036854775807; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) using mint = atcoder::modint998244353; using mint1 = atcoder::modint1000000007; using Pa = std::pair; int Yes(bool x){ if(x) cout << "Yes"; else cout << "No"; cout << endl; return 0; } ll solve(deque &A){ if(A.size() < 2){ return 0; } auto [a, b] = A.front(); A.pop_front(); if(a == 0){ return solve(A); } auto [c, d] = A.front(); A.pop_front(); if(A.size() == 0){ return (b / 2) * d; } auto [e, f] = A.front(); A.pop_front(); A.push_front({e, f+(b/2)*2}); ll x = (b/2)*d; x += solve(A); return x; } int main(){ string S; cin >> S; ll N = S.size(); deque A; ll x = 0; rep(i, N){ if(i == 0 || S[i-1] == S[i]){ x++; } else{ A.push_back({S[i-1]-'0', x}); x = 1; } } A.push_back({S[N-1]-'0', x}); cout << solve(A); }