#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    string s; cin >> s;
    if(s == "0") break;
    int n = (int)(s.size());
    vector<int> a(n);
    for(int i=0;i<n;++i) {
      a[i] = s[i] - '0';
    }
    vvi dp(n, vi(11, 0));
    dp[0][a[0]] = 1;
    for(int i=0;i<n-1;++i) {
      if(a[i+1] != 0) dp[i+1][a[i+1]] = 1;
      for(int j=0;j<11;++j) {
        dp[i+1][(j*10+a[i+1])%11] += dp[i][j];
      }
    }
    int ans = 0;
    for(int i=0;i<n;++i) {
      ans += dp[i][0];
    }
    cout << ans << endl;
  }
}

