#include <bits/stdc++.h>
using namespace std;
int main() {
  do {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
  } while (false);
  string str;
  cin >> str;
  unordered_map<int, long long> dp;
  long long ans = 0;
  auto state = [&](int a, int b, int c) { return a * 121 + b * 11 + c; };
  for (int i = 0; i < str.size(); i++) {
    unordered_map<int, long long> nxt;
    int c = str[i] - '0';
    if (c) {
      nxt[state(1, c, 9)] = 1;
    }
    for (const auto &it : dp) {
      int x = it.first / 121, y = it.first / 11 % 11, z = it.first % 11;
      long long val = it.second;
      if (c < (x + y - 1 + 11) % 11) {
        auto calc_sum = [&](int l, int r) {
          if (l > r) {
            r += 11;
          }
          return (l + r) * (r - l + 1) / 2 % 11;
        };
        int yy = (calc_sum(x, x + y - 2) + c + 1) % 11;
        int xx = (x + z) % 11, zz = calc_sum(x, x + z - 1);
        nxt[state(xx, yy, zz)] += val;
      }
    }
    dp.swap(nxt);
    for (const auto &it : dp) {
      ans += it.second;
    }
  }
  cout << ans << endl;
  return 0;
}
