#include<iostream>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	string s;
	while(cin>>s,s!="0"){
		int ans=0,c[2][11]={0},d;
		rep(i,s.size()){
			d=(i&1?10:1)*(s[i]-'0');
			rep(j,11)c[i&1][(j+d)%11]=c[i&1^1][j];
			if(s[i]!='0')c[i&1][d%11]++;
			ans+=c[i&1][0];
		}
		cout<<ans<<endl;
	}
	return 0;
}