#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  for(string s; cin >> s;) {
    if(s == "0") break;

    int n = s.size();
    rep(i, n) s[i] -= '0';

    static int dp[2][11];
    zero(dp);

    int ans = 0;

    rep(i, n) {
      zero(dp[(i+1)&1]);
      if(s[i] != 0) dp[(i+1)&1][(int)s[i]] ++;
      rep(j, 11) {
        int nj = (j * 10 + s[i]) % 11;
        dp[(i+1)&1][nj] += dp[i&1][j];
      }
      ans += dp[(i+1)&1][0];
    }

    cout << ans << endl;

  }
  
  return 0;
}