#include <iostream>
#include <string>
#include <vector>

using namespace std;

int solve(string s){
    int res = 0;
    vector<vector<int> > dp(2, vector<int>(11, 0));
    for(int i=0; i<(int)s.size(); ++i){
        int k = s[i] - '0';
        dp[i & 1].assign(11, 0);
        for(int j=0; j<11; ++j)dp[i & 1][(10 * j + k) % 11] += dp[~i & 1][j];
        if(k)dp[i & 1][k]++;
        res += dp[i & 1][0];
    }
    return res;
}

int main(){
    for(string in; cin >> in, in != "0";)cout << solve(in) << '\n';
    return 0;
}