loop {
	str = gets.chomp
	break if str == ?0

	a = str.each_char.map.with_index {|c, i|
		i.even? ? c.to_i : - c.to_i % 11
	}

	count = Hash.new(0)
	a.inject(0){|s, x|
		s = (s + x) % 11
		count[s] += 1
		s
	}

	total = 0
	a.each{|x|
		total += count[0] if x > 0
		count[x] -= 1
		new_count = {}
		count.each{|y, k|
			new_count[(y - x) % 11] = k
		}
		count = new_count
	}
	p total
}