#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int dy[] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx[] = {-1, 0, 1, 1, 1, 0, -1, -1};

bool solve() {
	string S; cin >> S;
	int N = S.size();
	vector<int> U(N+1);
	if (S == "0") return (false);
	
	int base = 1;

	map<int, int> mp;
	mp[0]++;

	U[N] = 0;
	ll cnt = 0;
	for (int i = N-1; i >= 0; i--) {
		U[i] = (U[i+1] + base * (S[i]-'0')) % 11;
		if (S[i] != '0') cnt += mp[U[i]];
		mp[U[i]]++;
		(base *= 10) %= 11;
	}
	cout << cnt << endl;

	return (true);
}

int main() {
	while (solve());
}

