#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+5;

int read()
{
	int s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(int x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(int x,char c='\n')
{
	write(x);
	putchar(c);
}
bool a[N],flag=1;
int f[N],g[N];

signed main()
{
	int n=0,ans=0;
	char c=getchar();
	while ('0'<=c&&c<='1')
	{
		a[++n]=c-'0';
		c=getchar();
	}
	for (int i=1;i<=n;i++) f[i]=f[i-1]+!a[i];
	for (int i=n;i>=1;i--) g[i]=g[i+1]+!a[i];
	for (int i=1;i<=n;i++)
	if (a[i]) ans+=(f[i]+1+(i&1))/2+flag*g[i],flag^=1;
		 else flag=1;
	int tot=n-f[n]-1;
	print(ans+(1+tot/2)*(tot/2)+(tot&1?(tot+1)/2:0));

	return 0;
}