#include <bits/stdc++.h>
using namespace std;
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& i : v) is >> i;
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto& i : v) os << i << ' ';
  return os;
}
template <typename T, typename U>
istream& operator>>(istream& is, pair<T, U>& p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& p) {
  os << p.first << ' ' << p.second;
  return os;
}
template <typename T, typename U>
pair<T, U> operator-(pair<T, U> a, pair<T, U> b) {
  return make_pair(a.first - b.first, a.second - b.second);
}
template <typename T, typename U>
pair<T, U> operator+(pair<T, U> a, pair<T, U> b) {
  return make_pair(a.first + b.first, a.second + b.second);
}
int geta(int a, int d) {
  return a / 11 * 55 + 10 + (a % 11 - 1) * (a % 11) / 2 + d;
}
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rnd(long long l, long long r) {
  return (long long)(rng() % (r - l + 1)) + l;
}
long long rnd(long long r) { return rng() % r; }
long long rnd() { return rng(); }
long double rndf() { return (long double)rng() / (long double)ULLONG_MAX; }
long double rndf(long double l, long double r) { return rndf() * (r - l) + l; }
int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<vector<long long>> dp(n, vector<long long>(11, 0));
  dp[0][s[0] - '0'] = 1;
  for (int i = 0; i < n - 1; ++i) {
    for (int j = 0; j < 11; ++j) {
      for (int d = 0; d < j; ++d) {
        int u = geta(j, d) % 11;
        if (s[i + 1] - '0' == d) dp[i + 1][geta(j, d) % 11] += dp[i][j];
      }
    }
    if (s[i + 1] != '0') dp[i + 1][s[i + 1] - '0']++;
  }
  42;
  ;
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 11; ++j) {
      ans += dp[i][j];
    }
  }
  cout << ans << '\n';
  return 0;
}
