#include <bits/stdc++.h>
using namespace std;
int dp[11][100001];
int b[] = {10, 10, 0, 2, 5, 9, 3, 9, 5, 2, 0};
int main() {
  string s;
  cin >> s;
  long long ans = 0;
  for (int n = s.size(), i = 0; i < n; ++i) {
    int d = s[i] - '0';
    for (int j = d + 1; j < 11; ++j) {
      int k = (b[j] + d) % 11;
      dp[k][i + 1] = (dp[k][i + 1] + dp[j][i]);
    }
    if (d) {
      ++dp[d][i + 1];
    }
    for (int k = 0; k < 11; ++k) {
      ans += dp[k][i + 1];
    }
  }
  printf("%lld\n", ans);
  return 0;
}
