#include <bits/stdc++.h>
using namespace std;
template <typename G1, typename G2 = G1, typename G3 = G1>
struct triple {
  G1 first;
  G2 second;
  G3 T;
};
int sum(int x) { return x * (x + 1) / 2 % 11; }
int sum(int x, int y) { return (sum(y) - sum(x - 1) + 11) % 11; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int N = 11;
  vector<vector<vector<vector<triple<int>>>>> go(
      N,
      vector<vector<vector<triple<int>>>>(N, vector<vector<triple<int>>>(N)));
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      for (int k = 0; k < N; k++) {
        int x = sum((i - j) % 11 + 11, i - 1 + 2 * 11);
        int y = sum(i + 1, i + k);
        for (int h = 0; h < i; h++) {
          int a = (i + k + x + h + 1) % 11;
          int b = (x + h) % 11;
          int c = (y + i - h - 1 + 11) % 11;
          go[i][j][k].push_back({a, b, c});
        }
      }
  string s;
  cin >> s;
  vector<vector<vector<long long>>> cur(
      N, vector<vector<long long>>(N, vector<long long>(N)));
  vector<vector<vector<long long>>> next(
      N, vector<vector<long long>>(N, vector<long long>(N)));
  long long ans = 0;
  int n = s.size();
  for (int t = 0; t < n; t++) {
    for (int i = 0; i < N; i++)
      for (int j = 0; j < N; j++)
        for (int k = 0; k < N; k++) next[i][j][k] = 0;
    for (int i = 0; i < N; i++)
      for (int j = 0; j < N; j++)
        for (int k = 0; k < N; k++)
          if (s[t] - '0' < i && cur[i][j][k] > 0) {
            auto temp = go[i][j][k][s[t] - '0'];
            next[temp.first][temp.second][temp.T] += cur[i][j][k];
          }
    if (s[t] != '0') ++next[s[t] - '0'][s[t] - '0' - 1][9 - s[t] + '0'];
    for (int i = 0; i < N; i++)
      for (int j = 0; j < N; j++)
        for (int k = 0; k < N; k++) ans += next[i][j][k];
    swap(next, cur);
  }
  cout << ans << '\n';
  return 0;
}
