import scala.annotation.tailrec
import scala.collection.mutable

object Main extends App {
  import scala.io.StdIn._
  loop()
  @tailrec def loop(): Unit = {
    val str = readLine.trim
    if (str == "0") return
    val memo = Array.fill(str.length){Array.fill(11){-1}}
    val digits = str.map(_.asDigit).toArray
    println(digits.indices.filterNot(digits(_) == 0).map{i ⇒ search(i, 0, digits, memo)}.sum)
    loop()
  }
  def search(current: Int, prev: Int, digits: Array[Int], memo: Array[Array[Int]]): Int = {
    if (current == digits.length) return 0
    if (memo(current)(prev) >= 0) return memo(current)(prev)
    memo(current)(prev) = if ((digits(current) + prev * 10) % 11 == 0) 1 else 0
    memo(current)(prev) += search(current + 1, (digits(current) + prev * 10) % 11, digits, memo)
    memo(current)(prev)
  }
}

