#include<iostream>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
int table[11][100000];

int solve(vector<int> &in){
  int n=in.size();
  rep(i,n)rep(j,11)table[j][i]=0;
  if (in[0]!=0 )table[in[0]][0]=1;
  //((a+b*10+...+x*10^y)*10mod11 +zmod11)==
  //(z+a*10+b*100+...+x*10^(y+1))mod11
  REP(i,1,n){
    rep(j,11){
      table[(j*10+in[i])%11][i]+=table[j][i-1];
    }
    if (in[i]!=0)table[in[i]][i]++;
  }
  
  int ret=0;
  rep(i,n)ret+=table[0][i];
  return ret;
}

int main(){
  string a;
  while(cin>>a && a!="0"){
    vector<int> in;
    rep(i,a.size())in.push_back(a[i]-'0');
    cout << solve(in)<<endl;
  }
}