#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
char s[N];
struct info {
  char a[12];
  info() { memset(a, 0, sizeof(a)); }
  info operator+(const info &b) const {
    info ans;
    for (int i = (int)(0); i <= (int)(11); i++) ans.a[i] = b.a[a[i]];
    return ans;
  }
} tr[11], st[17][N];
long long ans;
int main() {
  for (int i = (int)(0); i <= (int)(9); i++) {
    for (int j = (int)(0); j <= (int)(11); j++)
      if (j <= i || j == 11)
        tr[i].a[j] = 11;
      else
        tr[i].a[j] = (j * (j - 1) / 2 + i + 10) % 11;
  }
  scanf("%s", s + 1);
  int n = strlen(s + 1);
  for (int i = (int)(1); i <= (int)(n); i++) {
    s[i] -= '0';
    st[0][i] = tr[s[i]];
  }
  for (int i = (int)(1); i <= (int)(16); i++)
    for (int j = (int)(1); j <= (int)(n - (1 << i) + 1); j++)
      st[i][j] = st[i - 1][j] + st[i - 1][j + (1 << (i - 1))];
  for (int i = (int)(1); i <= (int)(n); i++)
    if (s[i]) {
      info tmp;
      for (int j = (int)(0); j <= (int)(10); j++) tmp.a[j] = j;
      int ri = i + 1;
      for (int j = (int)(16); j >= (int)(0); j--)
        if (ri + (1 << j) - 1 <= n) {
          info ttmp = tmp + st[j][ri];
          if (ttmp.a[s[i]] != 11) tmp = ttmp, ri += 1 << j;
        }
      ans += ri - i;
    }
  printf("%lld\n", ans);
}
