#include<stdio.h>
int main(){
  char s[100010];
  int i,j,r;
  while(scanf("%s",s),s[0]-'0'){
    int a[15]={};
    for(i=r=0;s[i];i++){
      int b[15]={};
      for(j=0;j<11;j++)b[(j*10+s[i]-'0')%11]+=a[j];
      for(j=0;j<11;j++)a[j]=b[j];
      if(s[i]-'0')a[s[i]-'0']++;
      r+=b[0];
      //for(j=0;j<11;j++)printf("%2d ",j);printf("\n");
      //for(j=0;j<11;j++)printf("%2d ",a[j]);printf("\n\n");
      //a[0]=0;
    }
    printf("%d\n",r);
  }
  return 0;
}