#include "bits/stdc++.h"
using namespace std;
int dp[80000][11];
int main() {
	string s;
	while (cin >> s, s != "0") {
		memset(dp, 0, sizeof(dp));
		for (int i = 0; i < s.size(); i++) {
			if (s[i] != '0') dp[i][s[i] - '0']++;
		}
		for (int i = 0; i + 1 < s.size(); i++) {
			for (int j = 0; j < 11; j++) {
				dp[i + 1][(j * 10 + (s[i + 1] - '0')) % 11] += dp[i][j];
			}
		}
		int ans = 0;
		for (int i = 0; i < s.size(); i++) ans += dp[i][0];
		cout << ans << endl;
	}
}
