#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


void solve(string& s){
    int n=s.size();
    reverse(s.begin(),s.end());
    vector<int> cnt(11);
    cnt[0]=1;
    int sum=0;
    ll ans=0;
    rep(i,n){
        int x=s[i]-'0';
        if(i%2)x=11-x;
        sum=(sum+x)%11;
        if(s[i]!='0')ans+=cnt[sum];
        cnt[sum]++;
    }
    cout<<ans<<endl;
}
int main(){
    string s;
    while(cin>>s,s!="0")solve(s);
    return 0;
}
