#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstring>

using namespace std;

int dp[80001][11];

int main()
{
    string S;
    while (cin>>S, S!="0") {
        memset(dp, 0, sizeof(dp));
        
        for (int i=0; i<S.size(); i++) {
            int d = S[i] - '0';
            
            if (d>0) dp[i+1][d] = 1;
            for (int j=0; j<=10; j++) {
                dp[i+1][(j*10+d)%11] += dp[i][j];
            }
            
            // for (int j=0; j<=10; j++) cerr << dp[i+1][j] << " ";
            //  cerr << endl;
        }
        
        int ans = 0;
        for (int i=0; i<=S.size(); i++) {
            ans += dp[i][0];
        }
        cout << ans << endl;
    }
}