#include<stdio.h>
#include<stdlib.h>
#include<string.h>

char S[80005];
int i,j,k,l,r,I[80005];

int main()
{
	for(;gets(S),S[0]!='0';)
	{
		l=strlen(S);
		for(i=0,j=l-1;i<=j;i++,j--){k=S[i]-'0';S[i]=S[j]-'0';S[j]=k;}
		I[1]=S[0];
		for(i=2,k=-1;i<=l;i++,k*=-1)
		{
			I[i]=I[i-1]+S[i-1]*k;
		}
		r=0;
		for(i=0;i<=l;i++)
			for(j=i+1;j<=l;j++)
			{
				if(S[j-1]==0)continue;
				if((I[j]-I[i])%11==0)
					r++;
			}
		printf("%d\n",r);
	}
	return 0;
}