#include <bits/stdc++.h>
using namespace std;

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    vector<Int> res;
    string s;
    while (cin >> s and s != "0") {
        reverse(all(s));
        Int n = s.size();
        vector<Int> a(n);
        Int add = 1;
        for (Int i = 0; i < n; i++) {
            a[i] = (s[i] - '0') * add % 11;
            add = add * 10 % 11;
        }
        for (int i = 0; i < n - 1; i++) {
            a[i + 1] += a[i];
            a[i + 1] %= 11;
        }
        Int cnt = 0;
        map<Int, Int> mp;
        mp[0]++;
        for (Int i = 0; i < n; i++) {
            if (s[i] != '0')  {
                cnt += mp[a[i]];
            }
            mp[a[i]]++;
        }
        res.push_back(cnt);
    }
    for (Int i = 0; i < (Int)res.size(); i++) {
        dump(res[i]);
    }
    return 0;
}

