#include <bits/stdc++.h>
using namespace std;
int las, now, que[2][200100][3], t[2], in[2][11][11][11];
long long f[2][11][11][11];
void put(int w, int a, int b, int c) {
  in[w][a][b][c] = 1;
  ++t[w];
  que[w][t[w]][0] = a;
  que[w][t[w]][1] = b;
  que[w][t[w]][2] = c;
}
bool inque(int w, int a, int b, int c) { return in[w][a][b][c]; }
void release(int w, int *a) {
  f[w][a[0]][a[1]][a[2]] = 0;
  in[w][a[0]][a[1]][a[2]] = 0;
}
int main() {
  int las = 1, now = 0;
  long long ans = 0;
  for (char c; (c = getchar()) > 47 && c < 58;) {
    int x = c - 48;
    las ^= 1;
    now ^= 1;
    t[now] = 0;
    if (x) put(now, x, x - 1, 9 - x), f[now][x][x - 1][9 - x] = 1;
    for (int i = 1; i <= t[las]; ++i) {
      int A = que[las][i][0], B = que[las][i][1], C = que[las][i][2];
      ans += f[las][A][B][C];
      if (A <= x) continue;
      int a, b, c;
      a = (A + C + (A - B + 10) * (11 - A + B) / 2 + A * (A - 1) / 2 + x + 1) %
          11;
      b = ((A - B + 10) * (11 - A + B) / 2 + A * (A - 1) / 2 + x) % 11;
      c = (A - x - 1 + (A + 11) * (10 - A) / 2 + (A + C + 1) * (A + C) / 2) %
          11;
      f[now][a][b][c] += f[las][A][B][C];
      if (!inque(now, a, b, c)) put(now, a, b, c);
    }
    for (int i = 1; i <= t[las]; ++i) release(las, que[las][i]);
  }
  for (int i = 1; i <= t[now]; ++i) {
    int A = que[now][i][0], B = que[now][i][1], C = que[now][i][2];
    ans += f[now][A][B][C];
  }
  printf("%I64d", ans);
}
