#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll md = 1000000007;
string S;

ll dp[100000][11];

void solve() {
    for(int i = 0; i <= S.size(); i++) {
        for(int j = 0; j <= 10; j++) {
            dp[i][j] = 0;
        }
    }
    S = "#" + S;
    ll ans = 0;
    for(ll i = 1; i < S.size(); i++) {
        for(int before = 0; before <= 10; before++) {
            int after = (before * 10 + S[i] - '0') % 11;
            dp[i][after] += dp[i-1][before];
        }
        if(S[i] != '0') {
            dp[i][S[i] - '0']++;
        }
        ans += dp[i][0];
    }
    cout << ans << endl;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        cin >> S;
        if(S == "0") break;
        solve();
    }
    return 0;
}
