#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> s;
  long long a[11], b[11], sol = 0;
  for (int i = 0; i < 11; i++) a[i] = 0;
  for (int l = 0; l < s.length(); l++) {
    int digit = s[l] - '0';
    for (int i = 0; i < 11; i++) {
      b[i] = a[i];
      a[i] = 0;
    }
    for (int i = 0; i < 11; i++)
      if (digit < i) a[(i * (i - 1) / 2 + 10 + digit) % 11] += b[i];
    if (digit != 0) a[digit]++;
    for (int i = 0; i < 11; i++) sol += a[i];
  }
  cout << sol << endl;
  return 0;
}
