#include <bits/stdc++.h>
#define ll long long
using namespace std;

signed main(){
	string s;
	while(cin >> s){
		if(s == "0") break;
		int amari = 0;
		ll dp[11] = {1},ans = 0;
		for(int i = 0;i < s.length();i++){
			if(i % 2) amari = (amari + s[i] - '0') % 11;
			else amari = (amari - (s[i] - '0') + 11) % 11;
			ans += dp[amari];
			if(i == s.length() - 1 || s[i + 1] != '0') dp[amari]++;
		}
		cout << ans << endl;
	}
}
