#include <bits/stdc++.h>
using namespace std;
char s[100010];
int f[100010][11][11], nxt[11][11][11], fir[100010];
int main() {
  for (int i = 0; i <= 10; i++)
    for (int j = 0; j <= 10; j++) {
      int cur = i, sum = j;
      while (cur % 11 != j) {
        sum = (sum + cur) % 11;
        cur++;
      }
      for (int k = 0; k <= 10; k++) {
        nxt[i][j][k] = sum;
        sum = (sum + j + k) % 11;
      }
    }
  int sum = 10;
  for (int i = 1; i <= 9; i++) {
    fir[i] = sum;
    sum = (sum + i) % 11;
  }
  scanf("%s", s + 1);
  int n = strlen(s + 1);
  for (int i = 1; i <= n; i++) {
    int tmp = s[i] - '0';
    if (tmp) f[i][tmp][fir[tmp]]++;
    if (i == n) break;
    for (int j = 0; j <= 10; j++)
      for (int k = 0; k <= 10; k++) {
        tmp = s[i + 1] - '0';
        if (tmp < j) {
          int c = (k + tmp) % 11;
          f[i + 1][c][nxt[j][k][tmp]] += f[i][j][k];
        }
      }
  }
  long long res = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= 10; j++)
      for (int k = 0; k <= 10; k++) res += f[i][j][k];
  printf("%I64d\n", res);
}
