#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    while(1){
	string s;
	cin>>s;
	if( s=="0" ) break;
	ll res = 0;
	vector<ll> cnt(11,0);
	for(ll i=0;i<s.size();i++){
	    vector<ll> tmp(11,0);
	    ll k = s[i]-'0';
	    for(int j=0;j<11;j++){
		tmp[(j*10+k)%11] += cnt[j];
	    }
	    if( k != 0 )tmp[ k ]++;
	    //cout<<s[i]<<endl;
	    //for(auto l:tmp)cout<<l<<' ';
	    //cout<<endl;
	    res += tmp[0];
	    cnt = tmp;
	}
	cout<<res<<endl;
    }
    return 0;
}

