#include<bits/stdc++.h>
/*
*/

using namespace std;

int main() {
	string S;
	while( cin >> S ) {
		if( S == "0" ) {
			break;
		}
		long long int ans = 0;
		vector<vector<long long int>>dp( S.length(), vector < long long int >( 2 ) );
		for( size_t i = 0; i < S.length(); i++ ) {
			if( i ) {
				dp[i] = dp[i - 1];
			}
			if( i % 2 ) {
				dp[i][0] += S[i] - '0';
			} else {
				dp[i][1] -= S[i] - '0';
			}
		}
		for( size_t i = 0; i < S.length(); i++ ) {
			dp[i][0] += dp[i][1];
			while( dp[i][0] < 0 ) {
				dp[i][0] += 11;
			}
			dp[i][0] %= 11;
		}
		vector<long long int>X( 11 );
		X[0]++;
		for( size_t i = 0; i < S.length(); i++ ) {
			ans += X[dp[i][0]];
			if( !( i < S.length() - 1 && S[i + 1] == '0' ) ) {
				X[dp[i][0]]++;
			}
		}

		cout << ans << endl;
	}
}