#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    while(1){
        cin >> s;
        if(s == "0") break;
        int n = s.size();
        vector<int> d(n + 1);
        d[0] = 0;
        rep(i, 0, n){
            if(i % 2 == 0){
                d[i + 1] = d[i] + (s[i] - '0');
            }else{
                d[i + 1] = d[i] - (s[i] - '0');
            }
        }
        map<int, int> mp;
        rep(i, 0, n + 1){
            mp[(d[i] % 11 + 11) % 11]++;
        }
        int ans = 0;
        for(auto it = mp.begin(); it != mp.end(); it++){
            ans += it -> second * (it -> second - 1) / 2;
        }
        int cnt[11] = {};
        rep(i, 0, n){
            int now = (d[i + 1] % 11 + 11) % 11;
            int pre = (d[i] % 11 + 11) % 11;
            if(s[i] == '0'){
                cnt[pre]++;
            }
            ans -= cnt[now];            
        }
        cout << ans << endl;
    }
}
