#include <iostream>
#include <algorithm>
#include <string>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main() {
	for(string s; cin >> s && s != "0";) {
		int ans = 0;
		int e[11] = {}, o = 0;
		REP(i,s.size()) {
			int d = s[i] - '0';
			if (d != 0) e[o]++;
			o = (o + (i & 1 ? 11 - d : d)) % 11;
			ans += e[o];
		}
		cout << ans << endl;
	}

	return 0;
}