#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

int main(){
  int dp[2][11];
  char c;
  while(scanf("%c", &c) != EOF && c != '0'){
    fill(dp[0], dp[2], 0);
    //cout << "c = " << c << endl;
    int ans = 0;
    dp[0][c-'0'] = 1;
    for(int i=0;scanf("%c", &c)&&c!='\n';++i){
      int ct = i%2, nt = (i+1)%2;
      /*
      for(int j=0;j<11;j++) cout << j << ' '; cout << endl;
      for(int j=0;j<11;j++) cout << dp[ct][j] << ' '; cout << endl;
      cout << "c' = " << c << endl;
      */
      for(int j=0;j<11;++j) dp[nt][j] = 0;
      if(c != '0') dp[nt][c-'0'] += 1;
      for(int j=0;j<11;++j) dp[nt][(j*10+c-'0')%11] += dp[ct][j];
      ans += dp[nt][0];
    }
    /*
    for(int j=0;j<11;j++) cout << j << ' '; cout << endl;
    for(int j=0;j<11;j++) cout << dp[0][j] << ' '; cout << endl;
    */
    cout << ans << endl;
  }
}