#include <bits/stdc++.h>
using namespace std;
long long m[11];
long long pos[100005][11];
string s;
int main() {
  cin >> s;
  for (int i = 1; i <= 10; i++) {
    m[i] = (m[i - 1] + i) % 11;
  }
  int n = s.size();
  for (int i = 0; i < 11; i++) pos[n - 1][i] = n - 1;
  for (int i = n - 2; i >= 0; i--) {
    for (int j = 0; j < 11; j++) {
      if (s[i + 1] - '0' >= j) {
        pos[i][j] = i;
      } else {
        int nw = m[(10 + j) % 11] + (s[i + 1] - '0') + 1 + 9;
        nw %= 11;
        pos[i][j] = pos[i + 1][nw];
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0') continue;
    ans += (pos[i][s[i] - '0'] - i + 1);
  }
  cout << ans << endl;
  return 0;
}
