#include <bits/stdc++.h>

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main()
{   
    string n;
    while (cin >> n && (int) (n[0] - '0') != 0) {
        int len = n.size();

        vector<vector<int>> dp(len, vector<int> (11, 0));
        dp[0][(int) (n[0] - '0')] = 1;

        int ans = 0;

        for (int i = 1; i < len; i++) {
            int xi = (int) (n[i] - '0');

            for (int j = 0; j <= 10; j++) {
                dp[i][(10*j+xi)%11] = dp[i-1][j];
            }
            if (xi != 0) dp[i][xi]++;
            ans += dp[i][0];
        }

        cout << ans << endl;
        
    }
}
