#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    string S;
    cin >> S;
    if (S == "0"){
      break;
    }
    int N = S.size();
    vector<int> cnt(11, 0);
    int sum = 0;
    int power = 1;
    cnt[0] = 1;
    int ans = 0;
    for (int i = N - 1; i >= 0; i--){
      sum += (S[i] - '0') * power;
      sum %= 11;
      if (S[i] != '0'){
        ans += cnt[sum];
      }
      cnt[sum]++;
      power *= 10;
      power %= 11;
    }
    cout << ans << endl;
  }
}
