import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

string s;

bool input() {
    s = readln.chomp;
    if (s == "0") return false;
    return true;
}

void solve() {
    //writeln("x: ", iota(0, 11, 1).array);
    auto C = new int[][](2, 11);
    auto N = s.length;
    int ans = 0;
    foreach (i; 0 .. N) {
        auto x = cast(int)(s[i] - '0');
        C[i & 1][] = 0;
        C[i & 1][x] = 1;
        if (x == 0) ans--;
        if (i >= 1) {
            auto p = cast(int)(s[i - 1] - '0');
            if (p == 0) C[(i + 1) & 1][0]--;
        }
        foreach (j; 0 .. 11) {
            C[i & 1][(j * 10 + x) % 11] += C[(i + 1) & 1][j];
        }
        ans += C[i & 1][0];
        //writeln(i, ": ", C[i & 1]);
    }
    writeln(ans);
}

void main() {
    while (input) solve;
}