def calc(a,i,j,l)
  n=0
  l=l%(10**(j+1))
  n=l/(10**i)
  if n==0
    return 0
  end
  if n%11==0
    return 1
  else
    return 0
  end
end

while n=gets.to_i
  if n==0
    break
  end
  count=0
  ans=0
  l=m=n
  while n>0
    n=n/10
    count+=1
  end
  a=Array.new(count)
  for i in 0..count-1
    a[i]=m%10
    m=m/10
  end
  for i in 0..count-2
    for j in i+1..count-1
      if a[j]==0
        next
      end
      ans+=calc(a,i,j,l)
    end
  end
  print ans,"\n"
end
  