#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
inline void cmin(int &x, int y) {
  if (y < x) x = y;
}
inline void cmax(int &x, int y) {
  if (y > x) x = y;
}
vector<int> v[11];
long long ans, dp[11], pd[11];
void calc() {
  vector<int> vn;
  vn.push_back(0);
  for (int i = 1; i <= 9; i++) vn.push_back(i);
  for (int i = 1; i < 100; i++) {
    int t = i % 11;
    if (vn.size() >= 100) break;
    for (int j = 0; j < t; j++) {
      vn.push_back(vn[i] * 10 + j);
      if (vn[i] <= 10) v[vn[i]].push_back((vn.size() - 1) % 11);
    }
  }
}
int main() {
  calc();
  string s;
  cin >> s;
  ans = 1;
  int val = s[0] - '0';
  dp[val] = 1;
  for (int i = 1; i < s.length(); i++) {
    int val = s[i] - '0';
    for (int j = val + 1; j <= 10; j++) {
      ans += dp[j];
      pd[v[j][val]] += dp[j];
    }
    if (val != 0) {
      pd[val]++;
      ++ans;
    }
    for (int j = 1; j <= 10; j++) {
      dp[j] = pd[j];
      pd[j] = 0;
    }
  }
  printf("%I64d", ans);
  return 0;
}
