#include <bits/stdc++.h>
using namespace std;
const int MN = 100005, M = 11, inf = 1000000005, mod = 1000000007;
const long long INF = 1000000000000000005LL;
struct state {
  int r, m, w;
};
state hop[M][M][M][M];
int dp[2][M][M][M];
char S[MN];
int main() {
  state pusty = {-1, 0, 0};
  for (int r = 0; r < M; ++r)
    for (int m = 0; m < M; ++m)
      for (int w = 0; w < M; ++w) {
        int sumam = 0, sumaw = 0;
        for (int i = 1; i <= m; ++i) sumam += (r - i + M);
        for (int i = 1; i <= w; ++i) sumaw += (r + i);
        sumam %= M;
        sumaw %= M;
        for (int c = 0; c < r; ++c) {
          hop[r][m][w][c].r = (sumam + c + 1 + r + w) % M;
          hop[r][m][w][c].m = (sumam + c) % M;
          hop[r][m][w][c].w = (r - c - 1 + sumaw) % M;
        }
        for (int c = r; c < M; ++c) hop[r][m][w][c] = pusty;
      }
  int n;
  scanf("%s", S);
  n = strlen(S);
  long long ans = 0LL;
  for (int i = n - 1; i >= 0; --i) {
    for (int r = 0; r < M; ++r)
      for (int m = 0; m < M; ++m)
        for (int w = 0; w < M; ++w) {
          state nast = hop[r][m][w][S[i] - '0'];
          if (nast.r == -1)
            dp[i & 1][r][m][w] = 0;
          else
            dp[i & 1][r][m][w] = 1 + dp[(i & 1) ^ 1][nast.r][nast.m][nast.w];
        }
    if (S[i] != '0')
      ans += (1 + dp[(i & 1) ^ 1][S[i] - '0'][S[i] - '1']['9' - S[i]]);
  }
  printf("%lld", ans);
}
