#include <bits/stdc++.h>
using namespace std;
const int MN = 1e5 + 100;
const int MNL = 20;
int N, s[MN];
char chr[MN];
int nex[11][MNL];
void pcpn(void) {
  for (int i = 1; i <= 10; i++) {
    for (int j = 0; j < i; j++) nex[i][0] += j;
    nex[i][0] = (nex[i][0] + 10) % 11;
  }
  for (int i = 0; i <= 10; i++)
    for (int j = 0; j < MNL - 1; j++) nex[i][j + 1] = nex[nex[i][j]][j];
}
int q[MN][11][MNL];
bool w[MN][11][MNL];
void pcpq(void) {
  for (int i = 0; i < N; i++)
    for (int j = 1; j <= 10; j++)
      if (w[i][j][0] = s[i] < j) q[i][j][0] = (nex[j][0] + s[i]) % 11;
  for (int i = N - 1; i >= 0; i--)
    for (int k = 1; k <= 10; k++)
      for (int j = 0; i + (1 << j + 1) <= N; j++)
        if (w[i][k][j + 1] = w[i][k][j] && w[i + (1 << j)][q[i][k][j]][j])
          q[i][k][j + 1] = q[i + (1 << j)][q[i][k][j]][j];
}
int lift(int x) {
  int k = s[x++];
  for (int i = 17; i >= 0; i--)
    if (x + (1 << i) <= N)
      if (w[x][k][i]) k = q[x][k][i], x += 1 << i;
  return x;
}
using ll = long long;
ll f;
int main(void) {
  pcpn();
  scanf(" %s", chr);
  for (N = 0; chr[N]; N++) s[N] = chr[N] - '0';
  pcpq();
  for (int i = 0; i < N; i++)
    if (s[i]) f += lift(i) - i;
  printf("%lld\n", f);
  return 0;
}
