#include <bits/stdc++.h>
using namespace std;
char st[100005];
int rk[100005][12][16 + 1];
int n, tmp[12];
long long ans;
int calc(int x) {
  if (x == 0) return 0;
  return tmp[x % 11] % 11;
}
int main() {
  scanf("%s", st + 1);
  n = strlen(st + 1);
  for (int i = 1; i <= 11; i++) tmp[i] = tmp[i - 1] + i % 11;
  for (int i = 1; i <= n; i++) {
    int x = st[i] - '0';
    for (int j = 0; j <= 10; j++) {
      if (x >= j)
        rk[i][j][0] = -1;
      else
        rk[i][j][0] = (calc(j - 1) + x + 10) % 11;
    }
  }
  for (int j = 0; j < 16; j++)
    for (int i = 1; i <= n; i++) {
      if (i + (1 << (j + 1)) - 1 > n) break;
      for (int l = 0; l <= 10; l++) {
        if (rk[i][l][j] < 0)
          rk[i][l][j + 1] = -1;
        else
          rk[i][l][j + 1] = rk[i + (1 << j)][rk[i][l][j]][j];
      }
    }
  ans = 0;
  for (int i = 1; i <= n; i++)
    if (rk[i][10][0] > 0) {
      int now_rk = 10;
      int x = i;
      for (int j = 16; j >= 0; j--) {
        if (x + (1 << j) - 1 > n) continue;
        if (rk[x][now_rk][j] >= 0) {
          x = x + (1 << j);
          now_rk = rk[x - (1 << j)][now_rk][j];
          ans += (1LL << j);
        }
      }
    }
  printf("%I64d\n", ans);
  return 0;
}
