#include <bits/stdc++.h>
const int MAXN = 1e5 + 20;
int sum[11];
inline void pre() {
  for (int i = 1; i < 11; ++i) sum[i] = sum[i - 1] + i;
}
inline int get_rank(const int &now_rank, const int &c) {
  return (9 + sum[(now_rank - 1 + 11) % 11] + c + 1) % 11;
}
long long dp[11][MAXN];
int s[MAXN];
int main() {
  pre();
  int tot = 0;
  for (char c = getchar(); c >= '0' && c <= '9'; c = getchar())
    s[++tot] = c - '0';
  long long ans = 0;
  for (int i = 1; i <= tot; ++i) {
    for (int r = s[i] + 1; r < 11; ++r)
      dp[get_rank(r, s[i])][i] += dp[r][i - 1];
    if (s[i] != 0) ++dp[s[i]][i];
    for (int r = 0; r < 11; ++r) ans += dp[r][i];
  }
  printf("%lld", ans);
}
