#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100001;
char str[MAX_N];
int main() {
  scanf("%s", str);
  long long res = 0;
  vector<int> prf(11, 0);
  for (int i = 0; str[i]; ++i) {
    int d = str[i] - '0';
    vector<int> prf2(11, 0);
    for (int j = d + 1; j < 11; ++j) {
      res += prf[j];
      int m = (6 * j * (j + 10) + 10 + d) % 11;
      prf2[m] += prf[j];
    }
    if (d > 0) {
      res += 1;
      prf2[d] += 1;
    }
    prf = prf2;
  }
  printf("%lld\n", res);
  return 0;
}
