#include <bits/stdc++.h>
using namespace std;
namespace mine {
void chmax(int &x, const long long y) { x = (x > y ? x : y); }
void chmin(int &x, const long long y) { x = (x < y ? x : y); }
long long qread() {
  long long ans = 0, f = 1;
  char c = getchar();
  while (c < '0' or c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while ('0' <= c and c <= '9') ans = ans * 10 + c - '0', c = getchar();
  return ans * f;
}
void write(long long num) {
  if (num < 0) putchar('-'), num = -num;
  if (num >= 10) write(num / 10);
  putchar('0' + num % 10);
}
void write1(long long num) {
  write(num);
  putchar(' ');
}
void write2(long long num) {
  write(num);
  putchar('\n');
}
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
  if (a <= -MOD) a += MOD;
}
long long qpower(long long x, int e) {
  long long ans = 1;
  while (e) {
    if (e & 1) ans = ans * x % MOD;
    x = x * x % MOD;
    e >>= 1;
  }
  return ans;
}
long long invm(long long x) { return qpower(x, MOD - 2); }
const int N = 1e5 + 10;
char str[N];
int cnt[2][11];
void main() {
  scanf("%s", str + 1);
  int n = strlen(str + 1);
  if (n == 1) {
    puts("1");
    return;
  }
  long long ans = 0;
  for (int i = 0, op = 0; i < n; i++, op ^= 1) {
    memset(cnt[op ^ 1], 0, sizeof cnt[op ^ 1]);
    if (str[i + 1] != '0') cnt[op ^ 1][str[i + 1] - '0'] = 1;
    if (i == 0) continue;
    for (int j = 0; j < 11; j++) {
      int to = (j * (j - 1) / 2 + str[i + 1] - '0' + 10) % 11;
      ans += cnt[op][j] * ((i == n - 1 and str[n] - '0' < j) ? 2 : 1);
      if (str[i + 1] - '0' < j) cnt[op ^ 1][to] += cnt[op][j];
    }
  }
  write(ans + (str[n] != '0'));
}
};  // namespace mine
int main() {
  srand(time(0));
  mine::main();
}
