#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int main() {
  string s;
  while(cin>>s,s!="0") {
    int dp[11] = {};
    int ans = 0;
    for (int i=s.size()-1; i>=0; --i) {
      int next[11] = {};
      dp[0]++;
      REP(j,11) {
        next[(j+(s[i]-'0')*(i%2?1:-1)+11)%11] += dp[j];
      }
      REP(j,11) dp[j]=next[j];
      // REP(j,11) cout << dp[j] << " "; cout << endl;
      if (s[i]!='0') ans += dp[0];
    }
    cout << ans << endl;
  }
}