#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1.01e9;
const long long infll = (long long)1.01e18;
const long double eps = 1e-9;
const long double pi = acos((long double)-1);
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int x) { return mrand() % x; }
const int k = 11;
int go[k][k];
void precalc() {
  int cur = 10;
  for (int r = 0; r < k; r++) {
    for (int i = 0; i < k; i++) {
      go[r][i] = -1;
    }
    for (int d = 0; d < r; d++) {
      go[r][d] = cur;
      cur = (cur + 1) % k;
    }
  }
}
const int maxn = (int)1e5 + 5;
int n;
string s;
char tmp[maxn];
bool read() {
  if (scanf("%s", tmp) < 1) {
    return false;
  }
  s = tmp;
  n = ((int)(s).size());
  return true;
}
int dp[maxn][k];
void solve() {
  for (int i = 0; i < k; i++) {
    dp[n][i] = 0;
  }
  for (int i = n - 1; i >= 0; i--) {
    int d = (s[i] - '0');
    for (int r = 0; r < k; r++) {
      auto &cur = dp[i][r];
      cur = 0;
      if (go[r][d] == -1) {
        continue;
      }
      cur = 1 + dp[i + 1][go[r][d]];
    }
  }
  long long res = 0;
  for (int i = 0; i < n; i++) {
    int d = (s[i] - '0');
    if (!d) {
      continue;
    }
    res += 1 + dp[i + 1][d];
  }
  printf("%lld\n", res);
}
int main() {
  precalc();
  while (read()) {
    solve();
  }
  return 0;
}
