#include <iostream>
#include <vector>
using namespace std;

int main(){
  string s;
  while(cin >> s, s != "0"){
    vector<long long> dp(11,0);
    long long ans = 0;
    for(auto c : s){
      int d = c-'0';
      vector<long long> dp_(11,0);
      for(int i = 0; i < 11; ++i){
        dp_[(i*10+d)%11] += dp[i];
      }
      if(d)
        dp_[d] += 1;
      dp = dp_;
      ans += dp[0];
    }
    cout << ans << endl;
  }
}

