#include <bits/stdc++.h>
using namespace std;
int const N = 100000;
int nxt[11][10], go[N][11];
char s[N + 1];
int main() {
  for (int i = 0; i < (int)(11); ++i)
    for (int j = 0; j < (int)(10); ++j) nxt[i][j] = -1;
  int z = 10;
  for (int i = 1; i < (int)(11); ++i)
    for (int j = 0; j < (int)(i); ++j) {
      nxt[i][j] = z;
      if (++z == 11) z = 0;
    }
  scanf("%s", s);
  int n = strlen(s);
  for (int i = 0; i < (int)(11); ++i) go[n - 1][i] = n - 1;
  for (int i = n - 2; i >= 0; --i)
    for (int j = 0; j < (int)(11); ++j)
      if (nxt[j][s[i + 1] - '0'] == -1)
        go[i][j] = i;
      else
        go[i][j] = go[i + 1][nxt[j][s[i + 1] - '0']];
  long long an = 0;
  for (int i = 0; i < (int)(n); ++i)
    if (s[i] != '0') an += go[i][s[i] - '0'] - i + 1;
  printf("%lld\n", an);
}
