#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

char str[1000000];
int mod[2][11];

int main() {
  while (scanf("%s", str), str[0] != '0') {
    MEMSET(mod, 0);
    int len = strlen(str);
    ll ans = 0;
    REP(i, len) {
      int prev = i & 1;
      int next = (i + 1) & 1;
      int num = str[i] - '0';
      MEMSET(mod[next], 0);
      REP(j, 11) {
        int nmod = (j * 10 + num) % 11;
        mod[next][nmod] = mod[prev][j];
      }
      ans += mod[next][0];
      if (num != 0) { mod[next][num]++; };
    }
    cout << ans << endl;
  }
}