#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif


int n,f[N][2],sum[N];
ll ans;
char s[N];

int main() { 
	scanf("%s", s+1);
	n = strlen(s+1);
	int cnt = 0;
	REP(i,1,n) if (s[i]=='1') ans+=(++cnt+1)/2;
	PER(i,1,n) {
		f[i][0]=f[i+1][0];
		f[i][1]=f[i+1][1];
		sum[i]=sum[i+1];
		if (s[i]=='1') ++f[i][i&1],++sum[i];
	}
	int pos = 1;
	while (s[pos]=='1') ++pos;
	if (pos>n) return printf("%lld\n",ans),0;
	cnt = 0;
	--pos;
	REP(i,1,pos) cnt += i&1;
	int now = 1;
	REP(i,pos+1,n) {
		int j = i;
		while (j<n&&s[j+1]=='0') ++j;
		ans += (j-i+1ll)*cnt;
		if (j==n) break;
		int k = j+1;
		while (k<n&&s[k+1]=='1') ++k;
		if ((k-j)%2&&pos%2) {
			REP(t,i,j-1) {
				ans += f[t][now];
				now ^= 1;
			}
			if (pos%2) ans += (sum[j]+1)/2;
			else ans += sum[j]/2;
			++pos;
		}
		else {
			REP(t,i,j) {
				ans += f[t][now];
				now ^= 1;
			}
		}
		REP(t,1,k-j) cnt += (pos+t)&1;
		pos += k-j;
		i = k;
	}
	printf("%lld\n", ans);
}
