#include <bits/stdc++.h>
using namespace std;
bool home = 1;
signed realMain();
signed main() {
  home = 0;
  if (home) {
    freopen("input", "r", stdin);
  } else {
    ios::sync_with_stdio(0);
    cin.tie(0);
  }
  realMain();
}
const long long undef = 12345;
long long spre[11][11], dp[11], nw[11], ret;
signed realMain() {
  for (long long i = 0; i < 11; i++)
    for (long long j = 0; j < 11; j++) spre[i][j] = undef;
  long long bef = 9;
  for (long long i = 1; i <= 11; i++) {
    for (long long j = 0; j < i % 11; j++) {
      spre[i % 11][j] = (++bef) % 11;
    }
  }
  string s;
  cin >> s;
  for (auto &ch : s) {
    long long dig = ch - '0';
    for (long long j = 0; j < 11; j++) nw[j] = 0;
    for (long long j = 0; j < 11; j++) {
      if (spre[j][dig] != undef) nw[spre[j][dig]] += dp[j];
    }
    if (dig > 0) nw[dig]++;
    for (long long j = 0; j < 11; j++) {
      dp[j] = nw[j];
      ret += dp[j];
    }
  }
  cout << ret << "\n";
  return 0;
}
