#include <bits/stdc++.h>
using namespace std;
int sum[11][11];
struct state {
  int a, b, c, d;
  state() { a = b = c = d = -1; }
  state(int _a, int _b, int _c, int _d) { a = _a, b = _b, c = _c, d = _d; }
  state trans(int i) {
    state res;
    res.d = (d + c) % 11;
    res.c = sum[d][c] % 11;
    res.b = (sum[d][b] + i) % 11;
    res.a = (a + c - b + res.b) % 11;
    return res;
  }
};
state trans[11][11][11][10];
queue<state> q, q_;
bool vis[11][11][11];
char s[100007];
long long cnt[11][11][11], cnt_[11][11][11];
int main() {
  for (int i = 0; i < 11; ++i)
    for (int j = 1; j < 11; ++j) sum[i][j] = sum[i][j - 1] + (i + j - 1) % 11;
  for (int a = 0; a < 11; ++a)
    for (int b = 0; b < 11; ++b)
      for (int c = 0; c < 11; ++c)
        for (int i = 0; i < 10; ++i) trans[a][b][c][i] = state(-1, -1, -1, -1);
  for (int i = 1; i <= 9; ++i) q.push(state(i, i - 1, 9, 1));
  while (!q.empty()) {
    state x = q.front();
    q.pop();
    for (int i = 0; i < x.a; ++i) {
      state y = x.trans(i);
      trans[x.a][x.b][x.c][i] = y;
      if (!vis[y.a][y.b][y.c]) {
        vis[y.a][y.b][y.c] = 1;
        q.push(y);
      }
    }
  }
  scanf("%s", s);
  int n = strlen(s);
  long long ans = 0;
  for (int j = 0; j < n; ++j) {
    int i = s[j] - '0';
    if (i) {
      q_.push(state(i, i - 1, 9, 1));
      ++cnt_[i][i - 1][9];
    }
    while (!q.empty()) {
      state x = q.front();
      q.pop();
      if (i < x.a) {
        state y = x.trans(i);
        if (!cnt_[y.a][y.b][y.c]) q_.push(y);
        cnt_[y.a][y.b][y.c] += cnt[x.a][x.b][x.c];
      }
    }
    while (!q_.empty()) q.push(q_.front()), q_.pop();
    for (int a = 0; a < 11; ++a)
      for (int b = 0; b < 11; ++b)
        for (int c = 0; c < 11; ++c) {
          ans += cnt_[a][b][c];
          cnt[a][b][c] = cnt_[a][b][c];
          cnt_[a][b][c] = 0;
        }
  }
  cout << ans << endl;
}
