#include <bits/stdc++.h>
using namespace std;
char str[100005];
long long int dp[11], nxt[11];
int main() {
  scanf("%s", &str);
  int n = strlen(str);
  memset(dp, 0, sizeof(dp));
  long long int ret = 0;
  for (int i = 0; i < n; i++) {
    int c = str[i] - '0';
    memset(nxt, 0, sizeof(nxt));
    for (int j = c + 1; j < 11; j++) {
      int to = (j * j - j - 2) / 2 + c;
      if (to < 0) to += 11;
      to %= 11;
      nxt[to] += dp[j];
    }
    if (c > 0) nxt[c]++;
    for (int j = 0; j < 11; j++) {
      ret += nxt[j];
      dp[j] = nxt[j];
    }
  }
  printf("%lld\n", ret);
  return 0;
}
