#include <bits/stdc++.h>
using namespace std;
char s[101000];
long long f[101000][11], ans;
int main(void) {
  scanf("%s", s);
  int n = strlen(s);
  for (int i = n - 1; ~i; i--) {
    int x = s[i] - 48;
    for (int j = x + 1; j < 11; j++) {
      f[i][j] += f[i + 1][((j - 1) * j / 2 + x + 10) % 11] + 1;
    }
    if (x) {
      ans += f[i + 1][x] + 1;
    }
  }
  cout << ans << endl;
  return 0;
}
